2016-08-14 13:36:50 +00:00
|
|
|
- set_fact:
|
|
|
|
credentials_file_lookup: "{{ lookup('file', '{{ credentials_file }}') }}"
|
|
|
|
ssh_public_key_lookup: "{{ lookup('file', '{{ ssh_public_key }}') }}"
|
|
|
|
|
2016-08-16 04:03:26 +00:00
|
|
|
- name: "Creating a new instance..."
|
2016-08-14 11:13:23 +00:00
|
|
|
gce:
|
2016-08-14 13:36:50 +00:00
|
|
|
instance_names: "{{ server_name }}"
|
2016-09-18 10:11:30 +00:00
|
|
|
zone: "{{ zone }}"
|
2016-08-14 11:13:23 +00:00
|
|
|
machine_type: n1-standard-1
|
2016-08-14 13:36:50 +00:00
|
|
|
image: ubuntu-1604
|
|
|
|
service_account_email: "{{ credentials_file_lookup.client_email }}"
|
|
|
|
credentials_file: "{{ credentials_file }}"
|
2016-08-14 13:51:24 +00:00
|
|
|
project_id: "{{ credentials_file_lookup.project_id }}"
|
2016-08-14 13:36:50 +00:00
|
|
|
metadata: '{"sshKeys":"root:{{ ssh_public_key_lookup }}"}'
|
2016-08-14 11:13:23 +00:00
|
|
|
register: google_vm
|
2016-08-16 03:32:44 +00:00
|
|
|
|
2016-08-16 04:03:26 +00:00
|
|
|
- name: Add the instance to an inventory group
|
2016-08-14 13:36:50 +00:00
|
|
|
add_host:
|
|
|
|
name: "{{ google_vm.instance_data[0].public_ip}}"
|
|
|
|
groups: vpn-host
|
|
|
|
ansible_ssh_user: ubuntu
|
|
|
|
ansible_python_interpreter: "/usr/bin/python2.7"
|
2016-08-18 08:16:22 +00:00
|
|
|
easyrsa_p12_export_password: "{{ easyrsa_p12_export_password }}"
|
2016-08-20 12:19:46 +00:00
|
|
|
cloud_provider: gce
|
|
|
|
ipv6_support: no
|
2016-08-16 03:32:44 +00:00
|
|
|
|
2016-08-14 13:51:24 +00:00
|
|
|
- name: Firewall configured
|
|
|
|
local_action:
|
|
|
|
module: gce_net
|
|
|
|
name: "{{ google_vm.instance_data[0].network }}"
|
|
|
|
fwname: "algo-ikev2"
|
|
|
|
allowed: "udp:500,4500;tcp:22"
|
|
|
|
state: "present"
|
|
|
|
src_range: 0.0.0.0/0
|
2016-08-16 03:32:44 +00:00
|
|
|
service_account_email: "{{ credentials_file_lookup.client_email }}"
|
2016-08-14 13:51:24 +00:00
|
|
|
credentials_file: "{{ credentials_file }}"
|
2016-08-16 03:32:44 +00:00
|
|
|
project_id: "{{ credentials_file_lookup.project_id }}"
|
2016-08-14 13:36:50 +00:00
|
|
|
|
2016-08-16 04:03:26 +00:00
|
|
|
- name: Waiting for SSH to become available
|
2016-08-14 13:36:50 +00:00
|
|
|
local_action: "wait_for port=22 host={{ google_vm.instance_data[0].public_ip }} timeout=320"
|