algo/roles/google_cloud/tasks/main.yml

30 lines
1.0 KiB
YAML
Raw Normal View History

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 }}') }}"
- name: "Creating a droplet..."
2016-08-14 11:13:23 +00:00
gce:
2016-08-14 13:36:50 +00:00
instance_names: "{{ server_name }}"
zone: "{{ zones[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 }}"
project_id: "{{ credentials_file_lookup.project_id }}"
metadata: '{"sshKeys":"root:{{ ssh_public_key_lookup }}"}'
2016-08-14 11:13:23 +00:00
register: google_vm
2016-08-14 13:36:50 +00:00
- name: Add the droplet to an inventory group
add_host:
name: "{{ google_vm.instance_data[0].public_ip}}"
groups: vpn-host
ansible_ssh_user: ubuntu
ansible_python_interpreter: "/usr/bin/python2.7"
dns_enabled: "{{ dns_enabled }}"
auditd_enabled: " {{ auditd_enabled }}"
- name: Wait for SSH to become available
local_action: "wait_for port=22 host={{ google_vm.instance_data[0].public_ip }} timeout=320"
2016-08-14 11:13:23 +00:00