From 6592caab084c39a1ed62f481ea37adb4e85c0f45 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Tue, 26 Nov 2019 16:10:17 +0100 Subject: [PATCH] facts: isolate container_binary facts in order to be able to call container_binary without having to run the whole ceph-facts role. Signed-off-by: Guillaume Abrioux (cherry picked from commit fe5ffe589e3cf19d1b03d73f3e2867a870c86192) --- .../purge-docker-cluster.yml | 24 +++++++++++-------- roles/ceph-facts/tasks/container_binary.yml | 9 +++++++ roles/ceph-facts/tasks/facts.yml | 10 ++------ 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 roles/ceph-facts/tasks/container_binary.yml diff --git a/infrastructure-playbooks/purge-docker-cluster.yml b/infrastructure-playbooks/purge-docker-cluster.yml index bef5da01c..21d6d9112 100644 --- a/infrastructure-playbooks/purge-docker-cluster.yml +++ b/infrastructure-playbooks/purge-docker-cluster.yml @@ -386,10 +386,11 @@ become: true tasks: - - name: set ceph_docker_registry value if not set - set_fact: - ceph_docker_registry: "docker.io" - when: ceph_docker_registry is not defined + - import_role: + name: ceph-defaults + - import_role: + name: ceph-facts + tasks_from: container_binary - name: disable node_exporter service service: @@ -423,10 +424,11 @@ - alertmanager tasks: - - name: set ceph_docker_registry value if not set - set_fact: - ceph_docker_registry: "docker.io" - when: ceph_docker_registry is not defined + - import_role: + name: ceph-defaults + - import_role: + name: ceph-facts + tasks_from: container_binary - name: stop services service: @@ -525,8 +527,6 @@ tasks: - import_role: name: ceph-defaults - - import_role: - name: ceph-facts - name: check if it is Atomic host stat: path=/run/ostree-booted @@ -536,6 +536,10 @@ set_fact: is_atomic: "{{ stat_ostree.stat.exists }}" + - import_role: + name: ceph-facts + tasks_from: container_binary + - name: remove ceph container image command: "{{ container_binary }} rmi {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}" tags: diff --git a/roles/ceph-facts/tasks/container_binary.yml b/roles/ceph-facts/tasks/container_binary.yml new file mode 100644 index 000000000..8e866bcbf --- /dev/null +++ b/roles/ceph-facts/tasks/container_binary.yml @@ -0,0 +1,9 @@ +--- +- name: check if podman binary is present + stat: + path: /usr/bin/podman + register: podman_binary + +- name: set_fact container_binary + set_fact: + container_binary: "{{ 'podman' if (podman_binary.stat.exists and ansible_distribution == 'Fedora') or (ansible_os_family == 'RedHat' and ansible_distribution_major_version == '8') else 'docker' }}" \ No newline at end of file diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index 6020ce1d5..789ecd635 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -8,19 +8,13 @@ set_fact: is_atomic: "{{ stat_ostree.stat.exists }}" -- name: check if podman binary is present - stat: - path: /usr/bin/podman - register: podman_binary +- name: import_tasks container_binary.yml + import_tasks: container_binary.yml - name: set_fact is_podman set_fact: is_podman: "{{ podman_binary.stat.exists }}" -- name: set_fact container_binary - set_fact: - container_binary: "{{ 'podman' if (podman_binary.stat.exists and ansible_distribution == 'Fedora') or (ansible_os_family == 'RedHat' and ansible_distribution_major_version == '8') else 'docker' }}" - # In case ansible_python_interpreter is set by the user, # ansible will not discover python and discovered_interpreter_python # will not be set