From a68fb968ca7ef1fa748d4f46d285bf159572063d Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Sun, 16 Nov 2025 11:20:57 +0100 Subject: [PATCH] fix: playbook execution order --- playbook.yaml | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/playbook.yaml b/playbook.yaml index 1a83fa2..c4013e6 100644 --- a/playbook.yaml +++ b/playbook.yaml @@ -1,8 +1,24 @@ --- -# execute this role -- name: "manage proxmox" - hosts: "all" +# update proxmox - first node +- name: "update proxmox - first node" + hosts: "{{ groups['proxmox'] | first }}" + become: true + tasks: + + # update cluster + - name: "update cluster" + tags: "update-cluster" + block: + + # enter ceph maintenance mode + - name: "set ceph enter maintenance mode" + ansible.builtin.import_tasks: "tasks/ceph/enter-maint.yaml" + + +# update proxmox - all nodes +- name: "update proxmox - all nodes" + hosts: "proxmox" become: true serial: 1 tasks: @@ -12,22 +28,22 @@ tags: "update-cluster" block: - # collect proxmox cluster nodes - - name: "collect proxmox cluster nodes" - set_fact: - first_node: "{{ groups['proxmox'] | default([]) | first | default('') }}" - last_node: "{{ groups['proxmox'] | default([]) | last | default('') }}" - - # enter ceph maintenance mode - - name: "set ceph enter maintenance mode" - ansible.builtin.import_tasks: "tasks/ceph/enter-maint.yaml" - when: "inventory_hostname == first_node" - # update proxmox cluster - name: "update proxmox cluster nodes" ansible.builtin.import_tasks: "tasks/proxmox/update-node.yaml" + +# update proxmox - last node +- name: "update proxmox - last node" + hosts: "{{ groups['proxmox'] | last }}" + become: true + tasks: + + # update cluster + - name: "update cluster" + tags: "update-cluster" + block: + # exit ceph maintenance mode - name: "exit ceph maintenance mode" ansible.builtin.import_tasks: "tasks/ceph/exit-maint.yaml" - when: "inventory_hostname == last_node"