2020-10-27 15:40:20 -04:00
|
|
|
---
|
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
tasks:
|
|
|
|
- name: set PVC maintenance mode
|
|
|
|
command: pvc maintenance on
|
2021-11-11 15:54:22 -05:00
|
|
|
run_once: yes
|
2020-10-27 15:40:20 -04:00
|
|
|
|
2021-11-11 15:54:22 -05:00
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
serial: 1
|
|
|
|
tasks:
|
2021-05-27 01:38:43 -04:00
|
|
|
- name: temporarily set norestart policy
|
|
|
|
copy:
|
|
|
|
dest: "/usr/sbin/policy-rc.d"
|
|
|
|
mode: "0755"
|
|
|
|
content: |
|
|
|
|
#!/bin/sh
|
|
|
|
exit 101
|
|
|
|
|
2020-10-27 15:40:20 -04:00
|
|
|
- name: aptitude full upgrade and cleanup
|
|
|
|
apt:
|
2021-05-20 11:02:47 -04:00
|
|
|
update_cache: yes
|
|
|
|
autoremove: yes
|
|
|
|
autoclean: yes
|
|
|
|
upgrade: full
|
2021-02-02 12:34:47 -05:00
|
|
|
|
|
|
|
- name: clean up obsolete kernels
|
2021-05-20 11:02:47 -04:00
|
|
|
command: /usr/local/sbin/kernel-cleanup.sh
|
2021-02-02 12:34:47 -05:00
|
|
|
|
|
|
|
- name: clean up obsolete packages
|
2021-05-20 11:02:47 -04:00
|
|
|
command: /usr/local/sbin/dpkg-cleanup.sh
|
2021-02-02 12:34:47 -05:00
|
|
|
|
2020-10-27 15:40:20 -04:00
|
|
|
- name: clean apt archives
|
|
|
|
file:
|
2021-05-20 11:02:47 -04:00
|
|
|
dest: /var/cache/apt/archives
|
|
|
|
state: absent
|
2020-10-27 15:40:20 -04:00
|
|
|
|
2021-05-27 01:38:43 -04:00
|
|
|
- name: remove temporarily set norestart policy
|
|
|
|
file:
|
|
|
|
dest: "/usr/sbin/policy-rc.d"
|
|
|
|
state: "absent"
|
|
|
|
force: "yes"
|
|
|
|
|
2022-05-17 16:25:52 -04:00
|
|
|
- name: check freshness
|
|
|
|
command: /usr/sbin/needrestart -p
|
2020-10-27 15:40:20 -04:00
|
|
|
register: freshness
|
2023-01-16 17:19:34 -05:00
|
|
|
changed_when: freshness.rc >= 1 and freshness.rc < 3
|
2020-10-27 15:40:20 -04:00
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: restart system cleanly
|
|
|
|
block:
|
|
|
|
- name: secondary node
|
2021-07-22 09:35:00 -04:00
|
|
|
command: 'pvc node secondary --wait {{ ansible_hostname }}'
|
2020-10-27 15:40:20 -04:00
|
|
|
ignore_errors: true
|
|
|
|
|
2021-07-22 09:35:00 -04:00
|
|
|
- name: wait 15 seconds for system to stabilize
|
2020-10-27 15:40:20 -04:00
|
|
|
pause:
|
2021-07-22 09:35:00 -04:00
|
|
|
seconds: 15
|
2020-10-27 15:40:20 -04:00
|
|
|
become: no
|
|
|
|
connection: local
|
|
|
|
|
|
|
|
- name: flush node
|
2021-05-20 11:02:47 -04:00
|
|
|
command: "pvc node flush {{ ansible_hostname }} --wait"
|
2021-10-13 10:34:36 -04:00
|
|
|
ignore_errors: yes
|
2020-10-27 15:40:20 -04:00
|
|
|
|
2021-07-06 09:28:59 -04:00
|
|
|
- name: make sure node is in flushed state
|
|
|
|
shell: "pvc node info {{ ansible_hostname }} | grep '^Domain State' | awk '{ print $NF }'"
|
|
|
|
register: pvcflush
|
|
|
|
failed_when: pvcflush.stdout != 'flushed'
|
|
|
|
until: pvcflush.stdout == 'flushed'
|
2021-07-22 16:16:27 -04:00
|
|
|
retries: 180
|
2021-07-06 09:28:59 -04:00
|
|
|
delay: 10
|
|
|
|
|
2020-10-27 15:40:20 -04:00
|
|
|
- name: ensure VMs are migrated away
|
|
|
|
shell: "virsh list | grep running | wc -l"
|
|
|
|
register: virshcount
|
|
|
|
failed_when: virshcount.stdout != "0"
|
|
|
|
until: virshcount.stdout == "0"
|
2021-07-22 16:16:27 -04:00
|
|
|
retries: 180
|
2020-10-27 15:40:20 -04:00
|
|
|
delay: 10
|
|
|
|
|
2021-01-07 11:11:16 -05:00
|
|
|
- name: wait 15 seconds for system to stabilize
|
2020-10-27 15:40:20 -04:00
|
|
|
pause:
|
2021-05-20 11:02:47 -04:00
|
|
|
seconds: 15
|
2021-01-07 11:11:16 -05:00
|
|
|
become: no
|
|
|
|
connection: local
|
|
|
|
|
|
|
|
- name: stop PVC daemon cleanly
|
|
|
|
service:
|
2021-05-20 11:02:47 -04:00
|
|
|
name: pvcnoded
|
2021-01-07 11:11:16 -05:00
|
|
|
state: stopped
|
|
|
|
|
|
|
|
- name: stop Zookeeper daemon cleanly
|
|
|
|
service:
|
2021-05-20 11:02:47 -04:00
|
|
|
name: zookeeper
|
2021-01-07 11:11:16 -05:00
|
|
|
state: stopped
|
|
|
|
|
|
|
|
- name: wait 15 seconds for system to stabilize
|
|
|
|
pause:
|
2021-05-20 11:02:47 -04:00
|
|
|
seconds: 15
|
2020-10-27 15:40:20 -04:00
|
|
|
become: no
|
|
|
|
connection: local
|
|
|
|
|
|
|
|
- name: set OSD noout
|
|
|
|
command: pvc storage osd set noout
|
|
|
|
|
2020-11-26 10:51:54 -05:00
|
|
|
- name: get running OSD services
|
|
|
|
shell: "systemctl | awk '{ print $1 }' | grep 'ceph-osd@[0-9]*.service'"
|
|
|
|
ignore_errors: true
|
|
|
|
register: osd_services
|
|
|
|
|
|
|
|
- name: stop Ceph OSD daemons cleanly
|
|
|
|
service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: stopped
|
|
|
|
ignore_errors: true
|
|
|
|
with_items: "{{ osd_services.stdout_lines }}"
|
|
|
|
|
|
|
|
- name: stop Ceph Monitor daemon cleanly
|
|
|
|
service:
|
|
|
|
name: "ceph-mon@{{ ansible_hostname }}"
|
|
|
|
state: stopped
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: stop Ceph Manager daemon cleanly
|
|
|
|
service:
|
|
|
|
name: "ceph-mgr@{{ ansible_hostname }}"
|
|
|
|
state: stopped
|
|
|
|
ignore_errors: true
|
|
|
|
|
2021-01-05 16:16:44 -05:00
|
|
|
- name: wait 30 seconds for system to stabilize
|
2020-11-26 10:51:54 -05:00
|
|
|
pause:
|
2021-05-20 11:02:47 -04:00
|
|
|
seconds: 30
|
2020-11-26 10:51:54 -05:00
|
|
|
become: no
|
|
|
|
connection: local
|
|
|
|
|
2020-10-27 15:40:20 -04:00
|
|
|
- name: restart system
|
|
|
|
reboot:
|
|
|
|
post_reboot_delay: 15
|
|
|
|
reboot_timeout: 1800
|
2020-11-26 10:51:54 -05:00
|
|
|
|
|
|
|
- name: make sure all OSDs are active
|
|
|
|
shell: "ceph osd stat | grep 'osds:' | awk '{ if ( $1 == $3 ) { print \"OK\" } else { print \"NOK\" } }'"
|
|
|
|
register: osdstat
|
|
|
|
failed_when: osdstat.stdout == "NOK"
|
|
|
|
until: osdstat.stdout == "OK"
|
|
|
|
retries: 60
|
|
|
|
delay: 10
|
|
|
|
|
|
|
|
- name: make sure all PGs have recovered
|
|
|
|
shell: "ceph health | grep -wo 'Degraded data redundancy'"
|
|
|
|
register: cephhealth
|
|
|
|
failed_when: cephhealth.stdout == "Degraded data redundancy'"
|
|
|
|
until: cephhealth.stdout == ""
|
|
|
|
retries: 60
|
|
|
|
delay: 10
|
|
|
|
|
2020-10-27 15:40:20 -04:00
|
|
|
- name: unset OSD noout
|
|
|
|
command: pvc storage osd unset noout
|
2021-10-07 16:31:52 -04:00
|
|
|
ignore_errors: yes
|
2020-10-27 15:40:20 -04:00
|
|
|
|
|
|
|
- name: unflush node
|
2020-11-26 10:51:54 -05:00
|
|
|
command: "pvc node ready {{ ansible_hostname }} --wait"
|
2021-10-13 10:34:36 -04:00
|
|
|
ignore_errors: yes
|
2021-01-07 10:49:23 -05:00
|
|
|
|
|
|
|
- name: make sure all VMs have returned
|
|
|
|
shell: "pvc node info {{ ansible_hostname }} | grep '^Domain State' | awk '{ print $NF }'"
|
|
|
|
register: pvcunflush
|
|
|
|
failed_when: pvcunflush.stdout != 'ready'
|
|
|
|
until: pvcunflush.stdout == 'ready'
|
2021-07-22 16:16:27 -04:00
|
|
|
retries: 180
|
2021-01-07 10:49:23 -05:00
|
|
|
delay: 10
|
|
|
|
|
2020-11-26 10:51:54 -05:00
|
|
|
- name: wait 30 seconds for system to stabilize
|
2020-10-27 15:40:20 -04:00
|
|
|
pause:
|
2021-05-20 11:02:47 -04:00
|
|
|
seconds: 30
|
2020-10-27 15:40:20 -04:00
|
|
|
become: no
|
|
|
|
connection: local
|
|
|
|
|
|
|
|
- name: reset any systemd failures
|
|
|
|
command: systemctl reset-failed
|
2022-05-17 16:25:52 -04:00
|
|
|
when: freshness.changed
|
2020-10-27 15:40:20 -04:00
|
|
|
|
2021-01-05 16:16:44 -05:00
|
|
|
- name: wait 30 seconds for system to stabilize
|
2020-10-27 15:40:20 -04:00
|
|
|
pause:
|
2021-05-20 11:02:47 -04:00
|
|
|
seconds: 30
|
2020-10-27 15:40:20 -04:00
|
|
|
become: no
|
|
|
|
connection: local
|
2021-11-11 15:54:22 -05:00
|
|
|
|
|
|
|
- hosts: all
|
|
|
|
remote_user: deploy
|
|
|
|
become: yes
|
|
|
|
become_user: root
|
|
|
|
gather_facts: yes
|
|
|
|
tasks:
|
|
|
|
- name: unset PVC maintenance mode
|
|
|
|
command: pvc maintenance off
|
|
|
|
run_once: yes
|