infra playbooks: use the right container binary

Use podman or docker wether they are available or not. podman will be
prioritized over docker if present.

Signed-off-by: Sébastien Han <seb@redhat.com>
pull/3367/head
Sébastien Han 2018-11-19 17:13:37 +01:00 committed by mergify[bot]
parent a4ad0d7720
commit 2814d36c93
4 changed files with 28 additions and 19 deletions

View File

@ -177,7 +177,8 @@
- not containerized_deployment - not containerized_deployment
- name: container | waiting for the containerized monitor to join the quorum... - 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 register: ceph_health_raw
until: > until: >
hostvars[mon_host]['ansible_hostname'] in (ceph_health_raw.stdout | from_json)["quorum_names"] or hostvars[mon_host]['ansible_hostname'] in (ceph_health_raw.stdout | from_json)["quorum_names"] or
@ -214,8 +215,8 @@
when: not containerized_deployment when: not containerized_deployment
- name: set containerized osd flags - name: set containerized osd flags
command: | command: >
docker exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster {{ cluster }} osd set {{ item }} {{ container_binary }} exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster {{ cluster }} osd set {{ item }}
with_items: with_items:
- noout - noout
- norebalance - norebalance
@ -240,7 +241,8 @@
- not containerized_deployment - not containerized_deployment
- name: container - get current fsid - 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 register: cluster_uuid_container
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
when: when:
@ -425,7 +427,7 @@
- name: set_fact docker_exec_cmd_osd - name: set_fact docker_exec_cmd_osd
set_fact: 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: when:
- containerized_deployment - containerized_deployment
@ -481,7 +483,7 @@
- name: set_fact docker_exec_cmd_osd - name: set_fact docker_exec_cmd_osd
set_fact: 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: when:
- containerized_deployment - containerized_deployment
@ -834,9 +836,10 @@
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
private: false private: false
- name: set_fact docker_exec_cmd_status - name: set_fact docker_exec_cmd_status
set_fact: 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: when:
- containerized_deployment - containerized_deployment

View File

@ -79,9 +79,9 @@
when: when:
- item != mon_to_kill - 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: 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 when: containerized_deployment
- name: exit playbook, if can not connect to the cluster - name: exit playbook, if can not connect to the cluster

View File

@ -57,9 +57,9 @@
private: false private: false
# post-task for preceding import # 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: 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 when: containerized_deployment
- name: exit playbook, if can not connect to the cluster - 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 # NOTE(leseb): using '>' is the only way I could have the command working
- name: find osd device based on the id - name: find osd device based on the id
shell: > 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 }} {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
list | awk -v pattern=osd.{{ item.0 }} '$0 ~ pattern {print $1}' list | awk -v pattern=osd.{{ item.0 }} '$0 ~ pattern {print $1}'
with_together: with_together:
@ -115,7 +115,7 @@
- name: find osd dedicated devices - container - name: find osd dedicated devices - container
shell: > 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 }} {{ 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]' 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: with_together:
@ -162,7 +162,7 @@
- name: zap ceph osd disks - name: zap ceph osd disks
shell: | shell: |
docker run --rm \ {{ container_binary }} run --rm \
--privileged=true \ --privileged=true \
--name ceph-osd-zap-{{ hostvars[item.1]['ansible_hostname'] }}-{{ item.0.stdout }} \ --name ceph-osd-zap-{{ hostvars[item.1]['ansible_hostname'] }}-{{ item.0.stdout }} \
-v /dev/:/dev/ \ -v /dev/:/dev/ \
@ -184,7 +184,7 @@
pkname=$(lsblk --nodeps -no PKNAME "${osd}"); pkname=$(lsblk --nodeps -no PKNAME "${osd}");
then then
echo zapping ceph osd partitions "${osd}"; echo zapping ceph osd partitions "${osd}";
docker run --rm \ {{ container_binary }} run --rm \
--privileged=true \ --privileged=true \
--name ceph-osd-zap-{{ hostvars[item.0]['ansible_hostname'] }}-$(basename "${osd}") \ --name ceph-osd-zap-{{ hostvars[item.0]['ansible_hostname'] }}-$(basename "${osd}") \
-v /dev/:/dev/ \ -v /dev/:/dev/ \

View File

@ -26,7 +26,7 @@
when: ireallymeanit != 'yes' when: ireallymeanit != 'yes'
- name: make sure docker is present and started - name: gather facts
hosts: hosts:
- "{{ mon_group_name|default('mons') }}" - "{{ mon_group_name|default('mons') }}"
@ -210,6 +210,10 @@
become: true become: true
tasks: tasks:
- import_role:
name: ceph-defaults
private: false
# pre-tasks for following importing # pre-tasks for following importing
- name: collect running osds and ceph-disk unit(s) - name: collect running osds and ceph-disk unit(s)
shell: | shell: |
@ -274,7 +278,7 @@
- name: check if containerized osds are already running - name: check if containerized osds are already running
command: > command: >
docker ps --filter='name=ceph-osd' {{ container_binary }} ps --filter='name=ceph-osd'
changed_when: false changed_when: false
failed_when: false failed_when: false
register: osd_running register: osd_running
@ -313,12 +317,14 @@
# post-task for preceding import - # post-task for preceding import -
- name: get num_pgs - 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 register: ceph_pgs
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
- name: container - waiting for clean pgs... - 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 register: ceph_health_post
until: > until: >
(((ceph_health_post.stdout | from_json).pgmap.pgs_by_state | length) > 0) (((ceph_health_post.stdout | from_json).pgmap.pgs_by_state | length) > 0)