2025-04-11 13:31:24 +02:00

60 lines
1.9 KiB
YAML

---
# handlers file for proxmox
- name: Configure cloud-init
community.general.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.general.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
until: cloudinit_status.stdout.find("done") != -1
retries: 100
delay: 36
ignore_errors: true