--- # handlers file for proxmox - name: Configure cloud-init community.proxmox.proxmox_kvm: api_host: "{{ proxmox_api_host }}" api_user: "{{ proxmox_api_user }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" agent: "enabled=1,fstrim_cloned_disks=1" cipassword: "{{ proxmox_instance_cloudinit_cipassword }}" ciuser: "{{ proxmox_instance_cloudinit_ciuser }}" ciupgrade: false ide: ide2: "{{ proxmox_instance_disks[0].storage }}:cloudinit" ipconfig: "{{ proxmox_instance_ipconfig }}" name: "{{ inventory_hostname }}" nameservers: "{{ proxmox_instance_cloudinit_nameservers }}" node: "{{ proxmox_instance_node }}" searchdomains: "{{ proxmox_instance_cloudinit_searchdomains }}" sshkeys: "{{ proxmox_instance_cloudinit_sshkeys }}" vmid: "{{ proxmox_instance_vmid }}" update: true update_unsafe: true when: proxmox_instance_cloudinit delegate_to: "{{ proxmox_delegate_to | default(omit) }}" - name: Start instance community.proxmox.proxmox_kvm: api_host: "{{ proxmox_api_host }}" api_user: "{{ proxmox_api_user }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" name: "{{ inventory_hostname }}" node: "{{ proxmox_instance_node }}" state: started when: - proxmox_start_instance - not rebooted.changed delegate_to: "{{ proxmox_delegate_to | default(omit) }}" - name: Wait SSH port is open ansible.builtin.wait_for: host: "{{ proxmox_instance_ssh_ip }}" port: "{{ proxmox_instance_ssh_port }}" search_regex: OpenSSH delay: 30 when: proxmox_start_instance delegate_to: "{{ proxmox_delegate_to | default(omit) }}" - name: Wait cloud-init ansible.builtin.command: cmd: cloud-init status when: proxmox_instance_cloudinit register: cloudinit_status changed_when: cloudinit_status.stdout_lines | select("search", "done") | list | length > 0 failed_when: cloudinit_status.rc == 1 until: cloudinit_status.stdout_lines | select("search", "done") | list | length > 0 retries: 100 delay: 36 ignore_errors: true - name: Disable maintenance mode on node ansible.builtin.command: argv: - ha-manager - crm-command - node-maintenance - disable - "{{ inventory_hostname_short }}" become: true register: proxmox_maintenance_disabled changed_when: proxmox_maintenance_disabled.rc == 0 listen: Disable maintenance mode # TO DEBUG: #- name: Wait until node quits maintenance mode # ansible.builtin.command: # argv: # - ha-manager # - status # become: true # register: proxmox_ha_manager_status # changed_when: >- # proxmox_ha_manager_status.stdout_lines | select("search", "lrm " + inventory_hostname_short +" (active") | list | length > 0 # retries: 20 # delay: 30 # until: >- # proxmox_ha_manager_status.stdout_lines | select("search", "lrm " + inventory_hostname_short + " (active") | list | length > 0 # listen: Disable maintenance mode