xoxys.hcloud_server/tasks/setup.yml
Robert Kaussow 42b794d7dc
All checks were successful
continuous-integration/drone/push Build is passing
fix variable
2020-05-17 22:19:24 +02:00

54 lines
1.6 KiB
YAML

---
- name: Provisioning VM '{{ hcloud_server.name }}'
hcloud_server:
name: "{{ hcloud_server.name }}"
server_type: "{{ hcloud_server.type | default('cx11') }}"
ssh_keys: "{{ hcloud_server.ssh_keys | default([]) }}"
image: "{{ hcloud_server.image | default('centos-7') }}"
location: "{{ hcloud_server.location | default('nbg1') }}"
api_token: "{{ hcloud_server.api_token | default(hcloud_server_default_api_token | default(omit)) }}"
state: present
register: __hcloud_server
async: 7200
poll: 0
delegate_to: localhost
- name: Wait for instance creation to complete
async_status:
jid: "{{ __hcloud_server.ansible_job_id }}"
register: __hcloud_job
until: hcloud_job.finished
retries: 300
delegate_to: localhost
- name: Populate instance config
set_fact:
hcloud_instance: {
'instance': "{{ __hcloud_job.hcloud_server.name }}",
'ipv4': "{{ __hcloud_job.hcloud_server.ipv4_address }}",
'ipv6': "{{ __hcloud_job.hcloud_server.ipv6 }}",
}
delegate_to: localhost
- name: Create volumes
hcloud_volume:
name: "{{ item.name }}"
server: "{{ hcloud_server.name }}"
size: "{{ item.size | default(10) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ hcloud_server_volumes }}"
loop_control:
label: "{{ item.name }}"
delegate_to: localhost
- name: Create reverse DNS entries
hcloud_rdns:
server: "{{ hcloud_server.name }}"
ip_address: "{{ item.addr }}"
dns_ptr: "{{ item.ptr }}"
state: "{{ item.state | default('present') }}"
loop: "{{ hcloud_server_rdns }}"
loop_control:
label: "{{ item.name }}"
delegate_to: localhost