From ab54c18b1b16f517827537d185d246f9d447faa5 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Sun, 10 Sep 2023 23:33:43 +0100 Subject: [PATCH] handlers --- infra/joplin/0000_proxmox_playbook.yaml | 33 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/infra/joplin/0000_proxmox_playbook.yaml b/infra/joplin/0000_proxmox_playbook.yaml index c8a1fc4..80ee4a8 100644 --- a/infra/joplin/0000_proxmox_playbook.yaml +++ b/infra/joplin/0000_proxmox_playbook.yaml @@ -36,16 +36,11 @@ clone: "{{ node }}-debian-12" storage: nvme register: create + notify: + - Initial boot - name: Debug ansible.builtin.debug: var: create - - name: Wait for VM to exist - community.general.proxmox_kvm: - state: current - register: vm - retries: 30 - delay: 10 - until: vm.status is defined - name: Add HOME NIC community.general.proxmox_nic: interface: net0 @@ -78,14 +73,30 @@ memory: 2048 - name: Retart VM # doesn't start if stopped when: - - vm.status is defined - - vm.status == "running" + - create.status is defined + - create.status == "running" community.general.proxmox_kvm: state: restarted timeout: 60 - name: Start VM # start if stopped when: - - vm.status is defined - - vm.status != "running" + - create.status is defined + - create.status != "running" community.general.proxmox_kvm: state: started + handlers: + - name: Initial boot + block: + - name: Start + community.general.proxmox_kvm: + state: started + register: start + retries: 30 + delay: 10 + until: start.status is defined + - name: Wait + ansible.builtin.wait_for: + timeout: 180 + - name: Poweroff + community.general.proxmox_kvm: + state: stopped