From 2814d36c93ef04d0091eed7ed16acefc34dc42e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 19 Nov 2018 17:13:37 +0100 Subject: [PATCH] infra playbooks: use the right container binary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use podman or docker wether they are available or not. podman will be prioritized over docker if present. Signed-off-by: Sébastien Han --- infrastructure-playbooks/rolling_update.yml | 17 ++++++++++------- infrastructure-playbooks/shrink-mon.yml | 4 ++-- .../shrink-osd-ceph-disk.yml | 12 ++++++------ ...tainerized-to-containerized-ceph-daemons.yml | 14 ++++++++++---- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/infrastructure-playbooks/rolling_update.yml b/infrastructure-playbooks/rolling_update.yml index bfaceffdc..7054bf8b6 100644 --- a/infrastructure-playbooks/rolling_update.yml +++ b/infrastructure-playbooks/rolling_update.yml @@ -177,7 +177,8 @@ - not containerized_deployment - name: container | waiting for the containerized monitor to join the quorum... - command: docker exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster "{{ cluster }}" -s --format json + command: > + {{ container_binary }} exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster "{{ cluster }}" -s --format json register: ceph_health_raw until: > hostvars[mon_host]['ansible_hostname'] in (ceph_health_raw.stdout | from_json)["quorum_names"] or @@ -214,8 +215,8 @@ when: not containerized_deployment - name: set containerized osd flags - command: | - docker exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster {{ cluster }} osd set {{ item }} + command: > + {{ container_binary }} exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster {{ cluster }} osd set {{ item }} with_items: - noout - norebalance @@ -240,7 +241,8 @@ - not containerized_deployment - name: container - get current fsid - command: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster {{ cluster }} fsid" + command: > + {{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster {{ cluster }} fsid register: cluster_uuid_container delegate_to: "{{ groups[mon_group_name][0] }}" when: @@ -425,7 +427,7 @@ - name: set_fact docker_exec_cmd_osd set_fact: - docker_exec_cmd_update_osd: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" + docker_exec_cmd_update_osd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" when: - containerized_deployment @@ -481,7 +483,7 @@ - name: set_fact docker_exec_cmd_osd set_fact: - docker_exec_cmd_update_osd: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" + docker_exec_cmd_update_osd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" when: - containerized_deployment @@ -834,9 +836,10 @@ - import_role: name: ceph-defaults private: false + - name: set_fact docker_exec_cmd_status set_fact: - docker_exec_cmd_status: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" + docker_exec_cmd_status: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" when: - containerized_deployment diff --git a/infrastructure-playbooks/shrink-mon.yml b/infrastructure-playbooks/shrink-mon.yml index e513ab975..f0665c75e 100644 --- a/infrastructure-playbooks/shrink-mon.yml +++ b/infrastructure-playbooks/shrink-mon.yml @@ -79,9 +79,9 @@ when: - item != mon_to_kill - - name: set_fact docker_exec_cmd build docker exec command (containerized) + - name: "set_fact docker_exec_cmd build {{ container_binary }} exec command (containerized)" set_fact: - docker_exec_cmd: "docker exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }}" + docker_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }}" when: containerized_deployment - name: exit playbook, if can not connect to the cluster diff --git a/infrastructure-playbooks/shrink-osd-ceph-disk.yml b/infrastructure-playbooks/shrink-osd-ceph-disk.yml index d4939a600..c9f9327be 100644 --- a/infrastructure-playbooks/shrink-osd-ceph-disk.yml +++ b/infrastructure-playbooks/shrink-osd-ceph-disk.yml @@ -57,9 +57,9 @@ private: false # post-task for preceding import - - name: set_fact docker_exec_cmd build docker exec command (containerized) + - name: "set_fact docker_exec_cmd build {{ container_binary }} exec command (containerized)" set_fact: - docker_exec_cmd: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" + docker_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" when: containerized_deployment - name: exit playbook, if can not connect to the cluster @@ -102,7 +102,7 @@ # NOTE(leseb): using '>' is the only way I could have the command working - name: find osd device based on the id shell: > - docker run --privileged=true -v /dev:/dev --entrypoint /usr/sbin/ceph-disk + {{ container_binary }} run --privileged=true -v /dev:/dev --entrypoint /usr/sbin/ceph-disk {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} list | awk -v pattern=osd.{{ item.0 }} '$0 ~ pattern {print $1}' with_together: @@ -115,7 +115,7 @@ - name: find osd dedicated devices - container shell: > - docker run --privileged=true -v /dev:/dev --entrypoint /usr/sbin/ceph-disk + {{ container_binary }} run --privileged=true -v /dev:/dev --entrypoint /usr/sbin/ceph-disk {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} list | grep osd.{{ item.0 }} | grep -Eo '/dev/([hsv]d[a-z]{1,2})[0-9]{1,2}|/dev/nvme[0-9]n[0-9]p[0-9]' with_together: @@ -162,7 +162,7 @@ - name: zap ceph osd disks shell: | - docker run --rm \ + {{ container_binary }} run --rm \ --privileged=true \ --name ceph-osd-zap-{{ hostvars[item.1]['ansible_hostname'] }}-{{ item.0.stdout }} \ -v /dev/:/dev/ \ @@ -184,7 +184,7 @@ pkname=$(lsblk --nodeps -no PKNAME "${osd}"); then echo zapping ceph osd partitions "${osd}"; - docker run --rm \ + {{ container_binary }} run --rm \ --privileged=true \ --name ceph-osd-zap-{{ hostvars[item.0]['ansible_hostname'] }}-$(basename "${osd}") \ -v /dev/:/dev/ \ diff --git a/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml b/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml index e44f20b49..80a956b8a 100644 --- a/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml +++ b/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml @@ -26,7 +26,7 @@ when: ireallymeanit != 'yes' -- name: make sure docker is present and started +- name: gather facts hosts: - "{{ mon_group_name|default('mons') }}" @@ -210,6 +210,10 @@ become: true tasks: + - import_role: + name: ceph-defaults + private: false + # pre-tasks for following importing - name: collect running osds and ceph-disk unit(s) shell: | @@ -274,7 +278,7 @@ - name: check if containerized osds are already running command: > - docker ps --filter='name=ceph-osd' + {{ container_binary }} ps --filter='name=ceph-osd' changed_when: false failed_when: false register: osd_running @@ -313,12 +317,14 @@ # post-task for preceding import - - name: get num_pgs - command: docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster "{{ cluster }}" -s --format json + command: > + {{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster {{ cluster }} -s --format json register: ceph_pgs delegate_to: "{{ groups[mon_group_name][0] }}" - name: container - waiting for clean pgs... - command: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster {{ cluster }} -s --format json" + command: > + {{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph --cluster {{ cluster }} -s --format json register: ceph_health_post until: > (((ceph_health_post.stdout | from_json).pgmap.pgs_by_state | length) > 0)