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 <gabrioux@redhat.com>
(cherry picked from commit fe5ffe589e)
pull/4807/head
Guillaume Abrioux 2019-11-26 16:10:17 +01:00 committed by Dimitri Savineau
parent 1f30327688
commit 6592caab08
3 changed files with 25 additions and 18 deletions

View File

@ -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:

View File

@ -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' }}"

View File

@ -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