Robert Kaussow
ed0baf8dea
All checks were successful
continuous-integration/drone/push Build is passing
59 lines
2.0 KiB
YAML
59 lines
2.0 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') }}"
|
|
backups: "{{ hcloud_server.backups | default('no') }}"
|
|
labels: "{{ hcloud_server.labels | default({}) }}"
|
|
api_token: "{{ hcloud_server.api_token | default(hcloud_server_default_api_token | default(omit)) }}"
|
|
state: present
|
|
changed_when: False
|
|
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) }}"
|
|
api_token: "{{ item.api_token | default(hcloud_server_default_api_token | default(omit)) }}"
|
|
state: "{{ item.state | default('present') }}"
|
|
loop: "{{ hcloud_server_volumes }}"
|
|
loop_control:
|
|
label: "{{ hcloud_server.name }}:{{ item.name }}"
|
|
delegate_to: localhost
|
|
|
|
- name: Create reverse DNS entries
|
|
hcloud_rdns:
|
|
server: "{{ hcloud_server.name }}"
|
|
ip_address: "{{ item.addr }}"
|
|
dns_ptr: "{{ item.ptr }}"
|
|
api_token: "{{ item.api_token | default(hcloud_server_default_api_token | default(omit)) }}"
|
|
state: "{{ item.state | default('present') }}"
|
|
loop: "{{ hcloud_server_rdns }}"
|
|
loop_control:
|
|
label: "{{ hcloud_server.name }}:{{ item.ptr }}"
|
|
delegate_to: localhost
|