refactor(ansible): reword task names
This commit is contained in:
1 parent
9b015b6987
commit
8e7ac456ce
1 file changed
+17
-37
@@ -97,7 +97,7 @@
|
|||||||
state: present
|
state: present
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
- name: Grow cloned scsi0 disk to requested size
|
- name: Resize disk to requested size
|
||||||
community.proxmox.proxmox_disk:
|
community.proxmox.proxmox_disk:
|
||||||
vmid: "{{ cloned_vm.vmid }}"
|
vmid: "{{ cloned_vm.vmid }}"
|
||||||
disk: scsi0
|
disk: scsi0
|
||||||
@@ -105,25 +105,21 @@
|
|||||||
state: resized
|
state: resized
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
- name: Start configured VM
|
- name: Start VM
|
||||||
community.proxmox.proxmox_kvm:
|
community.proxmox.proxmox_kvm:
|
||||||
vmid: "{{ cloned_vm.vmid }}"
|
vmid: "{{ cloned_vm.vmid }}"
|
||||||
state: started
|
state: started
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
- name: Wait for guest DNS publication
|
- name: Wait for guest DNS publication
|
||||||
ansible.builtin.command:
|
ansible.builtin.command: getent ahosts "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
|
||||||
argv:
|
|
||||||
- getent
|
|
||||||
- ahosts
|
|
||||||
- "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
|
|
||||||
register: guest_dns
|
register: guest_dns
|
||||||
changed_when: false
|
changed_when: false
|
||||||
until: guest_dns.rc == 0 and guest_dns.stdout | length > 0
|
until: guest_dns.rc == 0 and guest_dns.stdout | length > 0
|
||||||
retries: 30
|
retries: 30
|
||||||
delay: 5
|
delay: 5
|
||||||
|
|
||||||
- name: Wait for guest SSH port after DNS resolution
|
- name: Wait for guest SSH port
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
host: "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
|
host: "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
|
||||||
port: 22
|
port: 22
|
||||||
@@ -131,7 +127,7 @@
|
|||||||
timeout: 180
|
timeout: 180
|
||||||
sleep: 5
|
sleep: 5
|
||||||
|
|
||||||
- name: Add new guest to ephemeral inventory
|
- name: Add VM to dynamic inventory
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
|
name: "{{ vm_hostname }}.{{ vm_dns_domains[vm_vlan] }}"
|
||||||
groups: provisioned_vm
|
groups: provisioned_vm
|
||||||
@@ -146,50 +142,34 @@
|
|||||||
vars:
|
vars:
|
||||||
vm_timezone: Europe/Paris
|
vm_timezone: Europe/Paris
|
||||||
tasks:
|
tasks:
|
||||||
- name: Wait for Ansible connection with Python
|
- name: Wait for guest to be available
|
||||||
ansible.builtin.wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
connect_timeout: 10
|
connect_timeout: 10
|
||||||
sleep: 5
|
sleep: 5
|
||||||
timeout: 180
|
timeout: 180
|
||||||
|
|
||||||
- name: Wait for cloud-init with an external bound
|
- name: Wait for cloud-init status
|
||||||
ansible.builtin.raw: timeout 300 cloud-init status --wait --long
|
ansible.builtin.command: timeout 300 cloud-init status --wait --long
|
||||||
register: cloudinit_wait
|
register: cloudinit_wait
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: Show cloud-init wait diagnostics
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg:
|
|
||||||
- "stdout: {{ cloudinit_wait.stdout | trim }}"
|
|
||||||
- "stderr: {{ cloudinit_wait.stderr | trim }}"
|
|
||||||
|
|
||||||
- name: Require completed cloud-init
|
|
||||||
ansible.builtin.assert:
|
|
||||||
that:
|
|
||||||
- cloudinit_wait.rc in [0, 2]
|
|
||||||
- "cloudinit_wait.stdout is search('(?m)^status: done\\s*$')"
|
|
||||||
fail_msg: "VMID {{ provisioned_vmid }} cloud-init status is not complete (rc {{ cloudinit_wait.rc }}); VM left intact for inspection."
|
|
||||||
|
|
||||||
- name: Warn about degraded cloud-init completion
|
- name: Warn about degraded cloud-init completion
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "VMID {{ provisioned_vmid }} cloud-init completed with degraded status (rc 2); individual cloud-init operations may not have succeeded. Inspect the diagnostics before relying on this guest."
|
msg: "VMID {{ provisioned_vmid }} cloud-init completed with degraded status (rc 2); individual cloud-init operations may not have succeeded. Inspect the diagnostics before relying on this guest."
|
||||||
when: cloudinit_wait.rc == 2
|
when: cloudinit_wait.rc == 2
|
||||||
|
|
||||||
- name: Read guest timezone
|
- name: Assert cloud-init completion
|
||||||
ansible.builtin.command: timedatectl show --property=Timezone --value
|
ansible.builtin.assert:
|
||||||
register: guest_timezone_before
|
that:
|
||||||
changed_when: false
|
- cloudinit_wait.rc in [0, 2]
|
||||||
|
- "cloudinit_wait.stdout is search('(?m)^status: done\\s*$')"
|
||||||
|
fail_msg: "VMID {{ provisioned_vmid }} cloud-init status is not complete (rc {{ cloudinit_wait.rc }}); VM left intact for inspection."
|
||||||
|
|
||||||
- name: Set guest display timezone
|
- name: Set guest timezone
|
||||||
ansible.builtin.command:
|
ansible.builtin.command: timedatectl set-timezone "{{ vm_timezone }}"
|
||||||
argv: [timedatectl, set-timezone, "{{ vm_timezone }}"]
|
|
||||||
become: true
|
become: true
|
||||||
when: guest_timezone_before.stdout | trim != vm_timezone
|
|
||||||
|
|
||||||
- name: Verify final Ansible ping
|
|
||||||
ansible.builtin.ping:
|
|
||||||
|
|
||||||
- name: Report verified guest readiness
|
- name: Report verified guest readiness
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "VMID {{ provisioned_vmid }} at {{ inventory_hostname }} completed cloud-init and returned Ansible pong."
|
msg: "VMID {{ provisioned_vmid }} at {{ inventory_hostname }} completed cloud-init."
|
||||||
Reference in new issue
Block a user