diff --git a/playbook.yaml b/playbook.yaml new file mode 100644 index 0000000..1a83fa2 --- /dev/null +++ b/playbook.yaml @@ -0,0 +1,33 @@ +--- + +# execute this role +- name: "manage proxmox" + hosts: "all" + become: true + serial: 1 + tasks: + + # update cluster + - name: "update cluster" + 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" + + # exit ceph maintenance mode + - name: "exit ceph maintenance mode" + ansible.builtin.import_tasks: "tasks/ceph/exit-maint.yaml" + when: "inventory_hostname == last_node" diff --git a/readme.md b/readme.md index e5013a5..467d7bb 100644 --- a/readme.md +++ b/readme.md @@ -6,8 +6,8 @@ This role updates a Proxmox Cluster. | Operating System | Version | | --- | ----- | -| Debian | 12 | +| Proxmox VE | 9 | ## Tags -This role has no tags. +This role has one tag; `update-cluster`. diff --git a/tasks/ceph/enter-maint.yaml b/tasks/ceph/enter-maint.yaml index e4bc6df..3ea2785 100644 --- a/tasks/ceph/enter-maint.yaml +++ b/tasks/ceph/enter-maint.yaml @@ -7,7 +7,7 @@ # set ceph osd noout settings - name: "set ceph noout" ansible.builtin.shell: - cmd: "sudo ceph osd set noout" + cmd: "ceph osd set noout" changed_when: false failed_when: "ceph_noout_result.rc != 0" register: "ceph_noout_result" @@ -15,7 +15,7 @@ # set ceph osd nobackfill settings - name: "set ceph nobackfill" ansible.builtin.shell: - cmd: "sudo ceph osd set nobackfill" + cmd: "ceph osd set nobackfill" changed_when: false failed_when: "ceph_nobackfill_result.rc != 0" register: "ceph_nobackfill_result" @@ -23,7 +23,7 @@ # set ceph osd norebalance settings - name: "set ceph norebalance" ansible.builtin.shell: - cmd: "sudo ceph osd set norebalance" + cmd: "ceph osd set norebalance" changed_when: false failed_when: "ceph_norebalance_result.rc != 0" register: "ceph_norebalance_result" diff --git a/tasks/ceph/exit-maint.yaml b/tasks/ceph/exit-maint.yaml index 18cb8ca..ebed36c 100644 --- a/tasks/ceph/exit-maint.yaml +++ b/tasks/ceph/exit-maint.yaml @@ -7,7 +7,7 @@ # unset ceph osd noout settings - name: "unset ceph noout" ansible.builtin.shell: - cmd: "sudo ceph osd unset noout" + cmd: "ceph osd unset noout" changed_when: false failed_when: "ceph_noout_result.rc != 0" register: "ceph_noout_result" @@ -16,7 +16,7 @@ # unset ceph osd nobackfill settings - name: "unset ceph nobackfill" ansible.builtin.shell: - cmd: "sudo ceph osd unset nobackfill" + cmd: "ceph osd unset nobackfill" changed_when: false failed_when: "ceph_nobackfill_result.rc != 0" register: "ceph_nobackfill_result" @@ -25,19 +25,8 @@ # unset ceph osd norebalance settings - name: "unset ceph norebalance" ansible.builtin.shell: - cmd: "sudo ceph osd unset norebalance" + cmd: "ceph osd unset norebalance" changed_when: false failed_when: "ceph_norebalance_result.rc != 0" register: "ceph_norebalance_result" tags: "cluster" - - # wait for ceph to be healthy - - name: "wait for ceph to be healthy" - ansible.builtin.shell: - cmd: "sudo ceph -s" - changed_when: false - delay: 10 - register: "ceph_status" - retries: 30 - tags: "cluster" - until: "'HEALTH_OK' in ceph_status.stdout" diff --git a/tasks/main.yaml b/tasks/main.yaml deleted file mode 100644 index 1cc380e..0000000 --- a/tasks/main.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- - -# update cluster -- name: "update cluster" - 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.include_tasks: "ceph/enter-maint.yaml" - when: "inventory_hostname == first_node" - - # update proxmox cluster - - name: "update proxmox cluster nodes" - ansible.builtin.include_tasks: "proxmox/update-node.yaml" - - # exit ceph maintenance mode - - name: "exit ceph maintenance mode" - ansible.builtin.include_tasks: "ceph/exit-maint.yaml" - when: "inventory_hostname == last_node" diff --git a/tasks/proxmox/update-node.yaml b/tasks/proxmox/update-node.yaml index 4c88d3c..59d7434 100644 --- a/tasks/proxmox/update-node.yaml +++ b/tasks/proxmox/update-node.yaml @@ -3,8 +3,7 @@ # enter maintenance mode - name: "enter maintenance mode" ansible.builtin.shell: - cmd: - "sudo /usr/sbin/ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }}" + cmd: "/usr/sbin/ha-manager crm-command node-maintenance enable {{ inventory_hostname_short }}" changed_when: false failed_when: "maintenance_result.rc != 0" register: "maintenance_result" @@ -37,7 +36,7 @@ # install firmware updates - name: "install firmware updates" ansible.builtin.shell: - cmd: "sudo fwupdmgr upgrade --no-reboot-check --assume-yes" + cmd: "fwupdmgr upgrade --no-reboot-check --assume-yes" changed_when: false failed_when: false @@ -53,8 +52,7 @@ # exit maintenance mode - name: "exit maintenance mode" ansible.builtin.shell: - cmd: - "sudo /usr/sbin/ha-manager crm-command node-maintenance disable {{ inventory_hostname_short }}" + cmd: "/usr/sbin/ha-manager crm-command node-maintenance disable {{ inventory_hostname_short }}" changed_when: false delay: 10 failed_when: "maintenance_exit_result.rc != 0"