From 7ce011ed4883cf7848959a6a6f2d9c7f244b2a54 Mon Sep 17 00:00:00 2001 From: Teoman ONAY Date: Fri, 24 Nov 2023 18:28:11 +0100 Subject: [PATCH] purge: do not purge infra pkgs by default By default infra pkgs will remain installed after the cluster purge as they might already be there at Ceph installation and could be used by other processes on the nodes. Fixes: https://github.com/ceph/cephadm-ansible/issues/239 Signed-off-by: Teoman ONAY (cherry picked from commit 4f4a4b5bbcf46daef3ed95ca1bf482f74e714449) --- ceph_defaults/defaults/main.yml | 5 +++-- cephadm-preflight.yml | 14 ++++++++++++-- cephadm-purge-cluster.yml | 26 ++++++++++++++++---------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/ceph_defaults/defaults/main.yml b/ceph_defaults/defaults/main.yml index a8ea6fa..11e6b55 100644 --- a/ceph_defaults/defaults/main.yml +++ b/ceph_defaults/defaults/main.yml @@ -12,11 +12,12 @@ ceph_ibm_key: https://public.dhe.ibm.com/ibmdl/export/pub/storage/ceph/RPM-GPG-K ceph_release: quincy upgrade_ceph_packages: false ceph_pkgs: - - chrony - cephadm - - podman - ceph-common ceph_client_pkgs: - chrony - ceph-common +infra_pkgs: + - chrony + - podman client_group: clients diff --git a/cephadm-preflight.yml b/cephadm-preflight.yml index aa3f57f..846069a 100644 --- a/cephadm-preflight.yml +++ b/cephadm-preflight.yml @@ -189,12 +189,22 @@ register: result until: result is succeeded - - name: install prerequisites packages + - name: install prerequisites packages on servers package: - name: "{{ ceph_pkgs }}" + name: "{{ ceph_pkgs + infra_pkgs }}" state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}" register: result until: result is succeeded + when: group_names != [client_group] + + - name: install prerequisites packages on clients + package: + name: "{{ ceph_client_pkgs }}" + state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}" + register: result + until: result is succeeded + when: group_names == [client_group] + - name: ensure chronyd is running service: diff --git a/cephadm-purge-cluster.yml b/cephadm-purge-cluster.yml index 647f56a..de3c411 100644 --- a/cephadm-purge-cluster.yml +++ b/cephadm-purge-cluster.yml @@ -9,7 +9,7 @@ # # Usage: # -# ansible-playbook -i cephadm-purge-cluster.yml -e fsid= +# ansible-playbook -i cephadm-purge-cluster.yml -e fsid= -e infra_pkgs_purge= - name: check local prerequisites are in place @@ -55,7 +55,7 @@ - name: check cluster hosts have cephadm and the required fsid {{ fsid }} - hosts: all + hosts: all,!{{ client_group }} gather_facts: false become: true any_errors_fatal: true @@ -70,7 +70,6 @@ register: cephadm_exists changed_when: false failed_when: false - when: group_names != [client_group] - name: fail if cephadm is not available fail: @@ -78,14 +77,12 @@ The cephadm binary is missing on {{ inventory_hostname }}. To purge the cluster you must have cephadm installed on ALL ceph hosts. Install manually or use the preflight playbook. when: - - group_names != [client_group] - cephadm_exists.rc - name: check fsid directory given is valid across the cluster stat: path: /var/lib/ceph/{{ fsid }} register: fsid_exists - when: group_names != [client_group] - name: fail if the fsid directory is missing fail: @@ -93,7 +90,6 @@ The fsid directory '/var/lib/ceph/{{ fsid }}' can not be found on {{ inventory_hostname }} Is the fsid correct? when: - - group_names != [client_group] - not fsid_exists.stat.exists | bool @@ -133,7 +129,7 @@ - name: Purge ceph daemons from all hosts in the cluster - hosts: all + hosts: all,!{{ client_group }} become: true gather_facts: false any_errors_fatal: true @@ -144,7 +140,7 @@ - name: purge ceph daemons command: "cephadm rm-cluster --force --zap-osds --fsid {{ fsid }}" - when: group_names != [client_group] + changed_when: false - name: remove ceph packages @@ -157,9 +153,19 @@ import_role: name: ceph_defaults - - name: remove ceph packages + - name: remove ceph packages on ceph nodes package: - name: "{{ 'ceph-common' if group_names == [client_group] else ceph_pkgs | unique }}" + name: "{{ ceph_pkgs | union(infra_pkgs | intersect(infra_pkgs_purge | default([]))) }}" state: absent register: result until: result is succeeded + when: group_names != [client_group] + + - name: remove ceph packages on client nodes + package: + name: ceph-common + state: absent + register: result + until: result is succeeded + when: group_names == [client_group] +