From 3baced6e89d4d3af7d2190f4c587a4ee05f5977a Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Tue, 7 Apr 2020 11:07:06 +0200 Subject: [PATCH] Introducing tripleo_delegate_to on ceph health validation The purpose of this change is to fix the upgrade scenario without breaking the existing validation for the deployment phase. During the upgrade from queens, the default 'container_cli' is podman in the undercloud (which is updated), but it's still docker in the overcloud and this let the validation playbook to fail because we're computing this fact starting from inventory_hostname that still points to the undercloud. This issue can be solved by removing the delegation directive from tht and rely on tripleo delegate wrapper. This should be enough to access the overcloud (ceph_mon) variables, setting the right fact. Closes-Bug: #1871380 Change-Id: I46c4fbe0ef7b281d77bff82483eb0b48b4570bb3 --- playbooks/ceph-health.yaml | 3 ++- roles/ceph/defaults/main.yml | 1 + roles/ceph/tasks/ceph-health.yaml | 23 ++++++++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/playbooks/ceph-health.yaml b/playbooks/ceph-health.yaml index d25df0d4f..607e7ff3b 100644 --- a/playbooks/ceph-health.yaml +++ b/playbooks/ceph-health.yaml @@ -1,5 +1,5 @@ --- -- hosts: Controller +- hosts: ceph_mon vars: metadata: name: Check the status of the ceph cluster @@ -10,6 +10,7 @@ groups: - post-deployment - post-ceph + tripleo_delegate_to: "{{ groups['ceph_mon'] | default([]) }}" osd_percentage_min: 0 tasks: - include_role: diff --git a/roles/ceph/defaults/main.yml b/roles/ceph/defaults/main.yml index 301b69b8d..d75731e2a 100644 --- a/roles/ceph/defaults/main.yml +++ b/roles/ceph/defaults/main.yml @@ -4,3 +4,4 @@ fail_without_deps: false fail_on_ceph_health_err: false osd_percentage_min: 0 ceph_ansible_repo: "centos-ceph-nautilus" +container_client: "podman" diff --git a/roles/ceph/tasks/ceph-health.yaml b/roles/ceph/tasks/ceph-health.yaml index 0936c4e15..4e1c44064 100644 --- a/roles/ceph/tasks/ceph-health.yaml +++ b/roles/ceph/tasks/ceph-health.yaml @@ -5,12 +5,25 @@ ignore_errors: true register: ceph_mon_enabled changed_when: false + delegate_to: "{{ tripleo_delegate_to | first | default(omit) }}" - when: "ceph_mon_enabled is succeeded" + delegate_to: "{{ tripleo_delegate_to | first | default(omit) }}" block: - - name: Set container_cli fact from the inventory + - name: Check for docker cli + stat: + path: "/var/run/docker.sock" + register: check_docker_cli + check_mode: false + + - name: Set container_client fact set_fact: - container_cli: "{{ hostvars[inventory_hostname].container_cli|default('podman') }}" + container_client: |- + {% set container_cli = 'podman' %} + {% if check_docker_cli.stat.exists|bool %} + {% set container_client = 'docker' %} + {% endif %} + {{ container_client }} - name: Set container filter format set_fact: @@ -18,7 +31,7 @@ - name: Set ceph_mon_container name become: true - shell: "{{ container_cli }} ps {{ container_filter_format }} | grep ceph-mon" + shell: "{{ container_client }} ps {{ container_filter_format }} | grep ceph-mon" register: ceph_mon_container changed_when: false @@ -30,7 +43,7 @@ - name: Get ceph health become: true - shell: "{{ container_cli }} exec {{ ceph_mon_container.stdout }} ceph --cluster {{ ceph_cluster_name.stdout }} health | awk '{print $1}'" + shell: "{{ container_client }} exec {{ ceph_mon_container.stdout }} ceph --cluster {{ ceph_cluster_name.stdout }} health | awk '{print $1}'" register: ceph_health - name: Check ceph health @@ -57,7 +70,7 @@ - name: Get OSD stat percentage become: true shell: >- - "{{ container_cli }}" exec "{{ ceph_mon_container.stdout }}" ceph + "{{ container_client }}" exec "{{ ceph_mon_container.stdout }}" ceph --cluster "{{ ceph_cluster_name.stdout }}" osd stat -f json | jq '{{ jq_osd_percentage_filter }}' register: ceph_osd_in_percentage