From 2980a1f64e1167d9a78aa1d0b85267cb50160e1a Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Fri, 13 Sep 2024 14:52:58 +0200 Subject: [PATCH] Run ceph update if part of the deployment In case we run a minor update job where Ceph is deployed, the procedure should update Ceph according to a given container tag. This is useful to verify that the combination between the target Ceph version and the target RHOSO version is still healthy. This patch introduces the playbook/tasks that are supposed to invoke the Ceph update before openstack: - it results in a noop in case the ceph container image tag is the <= of the current deployed Ceph cluster - it is skipped by default if no "ceph_update" variable is passed or it is set to false - it can be skipped by passing --skip-tags ceph_update to the playbook By doing this we have the ability to trigger a Ceph update and make sure we continue to test the combination between the two projects, but at the same time we are not introducing an hard dependency as it can easily be skipped. Jira: https://issues.redhat.com/browse/OSPRH-9697 Signed-off-by: Francesco Pantano --- playbooks/update.yml | 36 +++++++++++++++++++ roles/cifmw_ceph_spec/defaults/main.yml | 1 + .../templates/initial_ceph.conf.j2 | 2 ++ roles/cifmw_cephadm/tasks/ceph_upgrade.yml | 6 ++-- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/playbooks/update.yml b/playbooks/update.yml index 2d518f2883..5a35158e04 100644 --- a/playbooks/update.yml +++ b/playbooks/update.yml @@ -49,6 +49,42 @@ dest: "/etc/yum.repos.d/" src: "{{ cifmw_basedir }}/artifacts/repositories/" +- name: Run Ceph update if part of the deployment + hosts: "{{ (groups[cifmw_ceph_target | default('computes')] | default([]))[:1] }}" + gather_facts: true + tasks: + - name: Update Ceph + when: cifmw_ceph_update | default(false) | bool + tags: + - update + - ceph_update + block: + - name: Get ceph.conf to inspect + become: true + ansible.builtin.slurp: + src: "{{ cifmw_ceph_conf }}" + vars: + cifmw_ceph_conf: "/etc/ceph/ceph.conf" + register: cephconf + + - name: Save /ceph.conf and inspect content + become: true + delegate_to: localhost + ansible.builtin.copy: + content: "{{ cephconf['content'] | b64decode }}" + dest: "/tmp/ceph.conf" + + - name: Extract the CephFSID from ceph.conf + ansible.builtin.set_fact: + ceph_fsid: "{{ lookup('ansible.builtin.ini', 'fsid', section='global', file='/tmp/ceph.conf') }}" + + - name: Perform a Ceph Update + ansible.builtin.import_role: + name: cifmw_cephadm + tasks_from: ceph_upgrade + vars: + cifmw_cephadm_fsid: "{{ ceph_fsid }}" + - name: Run update role hosts: "{{ cifmw_target_host | default('localhost') }}" gather_facts: false diff --git a/roles/cifmw_ceph_spec/defaults/main.yml b/roles/cifmw_ceph_spec/defaults/main.yml index cc78fed4ca..62dee6acf5 100644 --- a/roles/cifmw_ceph_spec/defaults/main.yml +++ b/roles/cifmw_ceph_spec/defaults/main.yml @@ -39,3 +39,4 @@ cifmw_ceph_spec_private_network: '' # Enable over-the-wire and on-disk encryption cifmw_ceph_spec_encryption: false +cifmw_cephadm_single_host_defaults: false diff --git a/roles/cifmw_ceph_spec/templates/initial_ceph.conf.j2 b/roles/cifmw_ceph_spec/templates/initial_ceph.conf.j2 index 3062ccbbff..15f55ab522 100644 --- a/roles/cifmw_ceph_spec/templates/initial_ceph.conf.j2 +++ b/roles/cifmw_ceph_spec/templates/initial_ceph.conf.j2 @@ -7,7 +7,9 @@ ms_mon_client_mode = secure ms_mon_cluster_mode = secure ms_mon_service_mode = secure {% endif %} +{% if cifmw_cephadm_single_host_defaults %} osd pool default size = 1 +{% endif %} {% if cifmw_ceph_spec_public_network %} public_network = {{ cifmw_ceph_spec_public_network }} {% endif %} diff --git a/roles/cifmw_cephadm/tasks/ceph_upgrade.yml b/roles/cifmw_cephadm/tasks/ceph_upgrade.yml index d1918fea23..31b8f33872 100644 --- a/roles/cifmw_cephadm/tasks/ceph_upgrade.yml +++ b/roles/cifmw_cephadm/tasks/ceph_upgrade.yml @@ -20,10 +20,10 @@ - name: Fail if health is HEALTH_WARN || HEALTH_ERR ansible.builtin.fail: - msg: Ceph is in {{ ceph_health.status }} state. + msg: Ceph is in {{ ceph_health.health.status }} state. when: - - ceph_health.status == 'HEALTH_WARN' or - ceph_health.status == 'HEALTH_ERR' + - ceph_health.health.status == 'HEALTH_WARN' or + ceph_health.health.status == 'HEALTH_ERR' - name: Build container image target ansible.builtin.set_fact: