|
| 1 | +--- |
| 2 | +- name: Check if host can enter maintenance mode |
| 3 | + ansible.builtin.import_role: |
| 4 | + name: stackhpc.cephadm.commands |
| 5 | + vars: |
| 6 | + cephadm_commands: |
| 7 | + - "orch host ok-to-stop {{ ansible_facts.nodename }}" |
| 8 | + |
| 9 | +# Annoyingly, 'ceph orch host ok-to-stop' does not exit non-zero when |
| 10 | +# it is not OK to stop, so we need to check for specific messages. |
| 11 | +- name: Assert that it is safe to stop host |
| 12 | + ansible.builtin.assert: |
| 13 | + that: |
| 14 | + # This one is seen for monitors |
| 15 | + - "'It is NOT safe' not in cephadm_commands_result.results[0].stderr" |
| 16 | + # This one is seen for OSDs |
| 17 | + - "'unsafe to stop' not in cephadm_commands_result.results[0].stderr" |
| 18 | + fail_msg: "{{ cephadm_commands_result.results[0].stderr }}" |
| 19 | + |
| 20 | +- name: Fail over Ceph manager |
| 21 | + when: '"Cannot stop active Mgr daemon" in cephadm_commands_result.results[0].stderr' |
| 22 | + block: |
| 23 | + - name: Extract full name of active Ceph manager |
| 24 | + ansible.builtin.set_fact: |
| 25 | + active_ceph_mgr: "{{ cephadm_commands_result.results[0].stderr | split | last | replace(\"'\", '') }}" |
| 26 | + |
| 27 | + - name: Ensure active manager has been switched to another node |
| 28 | + ansible.builtin.import_role: |
| 29 | + name: stackhpc.cephadm.commands |
| 30 | + vars: |
| 31 | + cephadm_commands: |
| 32 | + - "mgr fail {{ active_ceph_mgr }}" |
| 33 | + |
| 34 | +- name: Ensure host is in maintenance mode |
| 35 | + ansible.builtin.import_role: |
| 36 | + name: stackhpc.cephadm.commands |
| 37 | + vars: |
| 38 | + cephadm_commands: |
| 39 | + - "orch host maintenance enter {{ ansible_facts.nodename }}" |
0 commit comments