Commit 90f3f615 authored by Guillaume Abrioux's avatar Guillaume Abrioux Committed by Dimitri Savineau
Browse files

infra: introduce docker to podman playbook

This isn't backported from master because there are too many changes
between stable-3.2 and other newer branches.

NOTE:
This playbook  *doesn't* add podman support in stable-3.2 at all.
This is a tripleO dedicated playbook which is intended to be run
early during FFU workflow in order to prepare the OS upgrade.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1853457

Signed-off-by: default avatarGuillaume Abrioux <gabrioux@redhat.com>
parent 6daa2c9d
......@@ -555,6 +555,7 @@ dummy:
##########
# DOCKER #
##########
#container_binary: docker
#docker_exec_cmd:
#docker: false
#ceph_docker_image: "ceph/daemon"
......
......@@ -555,6 +555,7 @@ ceph_rhcs_version: 3
##########
# DOCKER #
##########
#container_binary: docker
#docker_exec_cmd:
#docker: false
ceph_docker_image: "rhceph/rhceph-3-rhel7"
......
# This playbook *doesn't* add podman support in stable-3.2 at all.
# This is a tripleO dedicated playbook which is intended to be run
# early during FFU workflow in order to prepare the OS upgrade.
- hosts:
- mons
- osds
- mdss
- rgws
- nfss
- rbdmirrors
- clients
- iscsigws
- iscsi-gws # for backward compatibility only!
- mgrs
gather_facts: false
become: True
any_errors_fatal: true
vars:
delegate_facts_host: True
roles:
- ceph-defaults
post_tasks:
- name: gather facts
setup:
gather_subset:
- 'all'
- '!facter'
- '!ohai'
when: not delegate_facts_host | bool or inventory_hostname in groups.get(client_group_name, [])
- name: gather and delegate facts
setup:
gather_subset:
- 'all'
- '!facter'
- '!ohai'
delegate_to: "{{ item }}"
delegate_facts: True
with_items: "{{ groups['all'] | difference(groups.get(client_group_name | default('clients'), [])) }}"
run_once: true
when: delegate_facts_host | bool
- hosts:
- "{{ mon_group_name | default('mons') }}"
- "{{ osd_group_name | default('osds') }}"
- "{{ mds_group_name | default('mdss') }}"
- "{{ rgw_group_name | default('rgws') }}"
- "{{ nfs_group_name | default('nfss') }}"
- "{{ mgr_group_name | default('mgrs') }}"
- "{{ iscsi_gw_group_name | default('iscsigws') }}"
- "{{ rbdmirror_group_name | default('rbdmirrors') }}"
gather_facts: false
become: true
roles:
- ceph-defaults
post_tasks:
- import_role:
name: ceph-facts
- import_role:
name: ceph-handler
- import_role:
name: ceph-docker-common
tasks_from: ceph_docker_version.yml
- name: set_fact docker2podman and container_binary
set_fact:
docker2podman: True
container_binary: podman
- import_role:
name: ceph-mon
tasks_from: docker2podman.yml
when: inventory_hostname in groups.get(mon_group_name, [])
- import_role:
name: ceph-iscsi-gw
tasks_from: docker2podman.yml
when: inventory_hostname in groups.get(iscsi_gw_group_name, [])
- import_role:
name: ceph-mds
tasks_from: systemd.yml
when: inventory_hostname in groups.get(mds_group_name, [])
- import_role:
name: ceph-mgr
tasks_from: docker2podman.yml
when: inventory_hostname in groups.get(mgr_group_name, [])
- import_role:
name: ceph-nfs
tasks_from: systemd.yml
when: inventory_hostname in groups.get(nfs_group_name, [])
- import_role:
name: ceph-osd
tasks_from: systemd.yml
when: inventory_hostname in groups.get(osd_group_name, [])
- import_role:
name: ceph-rbd-mirror
tasks_from: docker2podman.yml
when: inventory_hostname in groups.get(rbdmirror_group_name, [])
- import_role:
name: ceph-rgw
tasks_from: docker2podman.yml
when: inventory_hostname in groups.get(rgw_group_name, [])
# This is needed, otherwise containers won't come back after the reboot
# because this file is added later by the call of rolling_update playbook.
- name: add /etc/tmpfiles.d/ceph-common.conf
copy:
content: "d /run/ceph 0770 root root -"
dest: /etc/tmpfiles.d/ceph-common.conf
owner: root
group: root
mode: 0644
- name: reload systemd daemon
systemd:
daemon_reload: yes
\ No newline at end of file
......@@ -547,6 +547,7 @@ ceph_tcmalloc_max_total_thread_cache: 0
##########
# DOCKER #
##########
container_binary: docker
docker_exec_cmd:
docker: false
ceph_docker_image: "ceph/daemon"
......
---
- name: get docker version
command: docker --version
changed_when: false
check_mode: no
register: ceph_docker_version
- name: set_fact ceph_docker_version ceph_docker_version.stdout.split
set_fact:
ceph_docker_version: "{{ ceph_docker_version.stdout.split(' ')[2] }}"
\ No newline at end of file
......@@ -23,15 +23,8 @@
when:
- mon_use_fqdn
- name: get docker version
command: docker --version
changed_when: false
check_mode: no
register: ceph_docker_version
- name: set_fact ceph_docker_version ceph_docker_version.stdout.split
set_fact:
ceph_docker_version: "{{ ceph_docker_version.stdout.split(' ')[2] }}"
- name: include ceph_docker_version.yml
include_tasks: ceph_docker_version.yml
# Only include 'checks.yml' when :
# we are deploying containers without kv AND host is either a mon OR a nfs OR an osd,
......
---
- name: update apt cache
- name: handlers
when:
- not docker2podman | default(False) | bool
block:
- name: update apt cache
apt:
update-cache: yes
when:
- ansible_os_family == 'Debian'
- name: unset noup flag
- name: unset noup flag
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd unset noup"
delegate_to: "{{ groups[mon_group_name][0] }}"
changed_when: False
# We only want to restart on hosts that have called the handler.
# This var is set when he handler is called, and unset after the
# restart to ensure only the correct hosts are restarted.
- name: set _mon_handler_called before restart
# We only want to restart on hosts that have called the handler.
# This var is set when he handler is called, and unset after the
# restart to ensure only the correct hosts are restarted.
- name: set _mon_handler_called before restart
set_fact:
_mon_handler_called: True
listen: "restart ceph mons"
- name: copy mon restart script
- name: copy mon restart script
template:
src: restart_mon_daemon.sh.j2
dest: /tmp/restart_mon_daemon.sh
......@@ -29,7 +33,7 @@
when:
- mon_group_name in group_names
- name: restart ceph mon daemon(s) - non container
- name: restart ceph mon daemon(s) - non container
command: /usr/bin/env bash /tmp/restart_mon_daemon.sh
listen: "restart ceph mons"
when:
......@@ -42,7 +46,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: restart ceph mon daemon(s) - container
- name: restart ceph mon daemon(s) - container
command: /usr/bin/env bash /tmp/restart_mon_daemon.sh
listen: "restart ceph mons"
when:
......@@ -56,23 +60,23 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _mon_handler_called after restart
- name: set _mon_handler_called after restart
set_fact:
_mon_handler_called: False
listen: "restart ceph mons"
- name: set _osd_handler_called before restart
- name: set _osd_handler_called before restart
set_fact:
_osd_handler_called: True
listen: "restart ceph osds"
# This does not just restart OSDs but everything else too. Unfortunately
# at this time the ansible role does not have an OSD id list to use
# for restarting them specifically.
# This does not need to run during a rolling update as the playbook will
# restart all OSDs using the tasks "start ceph osd" or
# "restart containerized ceph osd"
- name: copy osd restart script
# This does not just restart OSDs but everything else too. Unfortunately
# at this time the ansible role does not have an OSD id list to use
# for restarting them specifically.
# This does not need to run during a rolling update as the playbook will
# restart all OSDs using the tasks "start ceph osd" or
# "restart containerized ceph osd"
- name: copy osd restart script
template:
src: restart_osd_daemon.sh.j2
dest: /tmp/restart_osd_daemon.sh
......@@ -84,7 +88,7 @@
- osd_group_name in group_names
- not rolling_update
- name: restart ceph osds daemon(s) - non container
- name: restart ceph osds daemon(s) - non container
command: /usr/bin/env bash /tmp/restart_osd_daemon.sh
listen: "restart ceph osds"
when:
......@@ -101,7 +105,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: restart ceph osds daemon(s) - container
- name: restart ceph osds daemon(s) - container
command: /usr/bin/env bash /tmp/restart_osd_daemon.sh
listen: "restart ceph osds"
when:
......@@ -118,17 +122,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _osd_handler_called after restart
- name: set _osd_handler_called after restart
set_fact:
_osd_handler_called: False
listen: "restart ceph osds"
- name: set _mds_handler_called before restart
- name: set _mds_handler_called before restart
set_fact:
_mds_handler_called: True
listen: "restart ceph mdss"
- name: copy mds restart script
- name: copy mds restart script
template:
src: restart_mds_daemon.sh.j2
dest: /tmp/restart_mds_daemon.sh
......@@ -139,7 +143,7 @@
when:
- mds_group_name in group_names
- name: restart ceph mds daemon(s) - non container
- name: restart ceph mds daemon(s) - non container
command: /usr/bin/env bash /tmp/restart_mds_daemon.sh
listen: "restart ceph mdss"
when:
......@@ -152,7 +156,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: restart ceph mds daemon(s) - container
- name: restart ceph mds daemon(s) - container
command: /usr/bin/env bash /tmp/restart_mds_daemon.sh
listen: "restart ceph mdss"
when:
......@@ -166,17 +170,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _mds_handler_called after restart
- name: set _mds_handler_called after restart
set_fact:
_mds_handler_called: False
listen: "restart ceph mdss"
- name: set _rgw_handler_called before restart
- name: set _rgw_handler_called before restart
set_fact:
_rgw_handler_called: True
listen: "restart ceph rgws"
- name: copy rgw restart script
- name: copy rgw restart script
template:
src: restart_rgw_daemon.sh.j2
dest: /tmp/restart_rgw_daemon.sh
......@@ -187,7 +191,7 @@
when:
- rgw_group_name in group_names
- name: restart ceph rgw daemon(s) - non container
- name: restart ceph rgw daemon(s) - non container
command: /usr/bin/env bash /tmp/restart_rgw_daemon.sh
listen: "restart ceph rgws"
when:
......@@ -200,7 +204,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: restart ceph rgw daemon(s) - container
- name: restart ceph rgw daemon(s) - container
command: /usr/bin/env bash /tmp/restart_rgw_daemon.sh
listen: "restart ceph rgws"
when:
......@@ -214,17 +218,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _rgw_handler_called after restart
- name: set _rgw_handler_called after restart
set_fact:
_rgw_handler_called: False
listen: "restart ceph rgws"
- name: set _nfs_handler_called before restart
- name: set _nfs_handler_called before restart
set_fact:
_nfs_handler_called: True
listen: "restart ceph nfss"
- name: copy nfs restart script
- name: copy nfs restart script
template:
src: restart_nfs_daemon.sh.j2
dest: /tmp/restart_nfs_daemon.sh
......@@ -235,7 +239,7 @@
when:
- nfs_group_name in group_names
- name: restart ceph nfs daemon(s) - non container
- name: restart ceph nfs daemon(s) - non container
command: /usr/bin/env bash /tmp/restart_nfs_daemon.sh
listen: "restart ceph nfss"
when:
......@@ -248,7 +252,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: restart ceph nfs daemon(s) - container
- name: restart ceph nfs daemon(s) - container
command: /usr/bin/env bash /tmp/restart_nfs_daemon.sh
listen: "restart ceph nfss"
when:
......@@ -262,17 +266,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _nfs_handler_called after restart
- name: set _nfs_handler_called after restart
set_fact:
_nfs_handler_called: False
listen: "restart ceph nfss"
- name: set _rbdmirror_handler_called before restart
- name: set _rbdmirror_handler_called before restart
set_fact:
_rbdmirror_handler_called: True
listen: "restart ceph rbdmirrors"
- name: copy rbd mirror restart script
- name: copy rbd mirror restart script
template:
src: restart_rbd_mirror_daemon.sh.j2
dest: /tmp/restart_rbd_mirror_daemon.sh
......@@ -283,7 +287,7 @@
when:
- rbdmirror_group_name in group_names
- name: restart ceph rbd mirror daemon(s) - non container
- name: restart ceph rbd mirror daemon(s) - non container
command: /usr/bin/env bash /tmp/restart_rbd_mirror_daemon.sh
listen: "restart ceph rbdmirrors"
when:
......@@ -296,7 +300,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: restart ceph rbd mirror daemon(s) - container
- name: restart ceph rbd mirror daemon(s) - container
command: /usr/bin/env bash /tmp/restart_rbd_mirror_daemon.sh
listen: "restart ceph rbdmirrors"
when:
......@@ -310,17 +314,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _rbdmirror_handler_called after restart
- name: set _rbdmirror_handler_called after restart
set_fact:
_rbdmirror_handler_called: False
listen: "restart ceph rbdmirrors"
- name: set _mgr_handler_called before restart
- name: set _mgr_handler_called before restart
set_fact:
_mgr_handler_called: True
listen: "restart ceph mgrs"
- name: copy mgr restart script
- name: copy mgr restart script
template:
src: restart_mgr_daemon.sh.j2
dest: /tmp/restart_mgr_daemon.sh
......@@ -331,7 +335,7 @@
when:
- mgr_group_name in group_names
- name: restart ceph mgr daemon(s) - non container
- name: restart ceph mgr daemon(s) - non container
command: /usr/bin/env bash /tmp/restart_mgr_daemon.sh
listen: "restart ceph mgrs"
when:
......@@ -344,7 +348,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: restart ceph mgr daemon(s) - container
- name: restart ceph mgr daemon(s) - container
command: /usr/bin/env bash /tmp/restart_mgr_daemon.sh
listen: "restart ceph mgrs"
when:
......@@ -358,17 +362,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _mgr_handler_called after restart
- name: set _mgr_handler_called after restart
set_fact:
_mgr_handler_called: False
listen: "restart ceph mgrs"
- name: set _tcmu_runner_handler_called before restart
- name: set _tcmu_runner_handler_called before restart
set_fact:
_tcmu_runner_handler_called: True
listen: "restart ceph tcmu-runner"
- name: copy tcmu-runner restart script
- name: copy tcmu-runner restart script
template:
src: restart_tcmu_runner.sh.j2
dest: /tmp/restart_tcmu_runner.sh
......@@ -379,7 +383,7 @@
when:
- iscsi_gw_group_name in group_names
- name: restart tcmu-runner
- name: restart tcmu-runner
command: /usr/bin/env bash /tmp/restart_tcmu_runner.sh
listen: "restart ceph tcmu-runner"
when:
......@@ -391,17 +395,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _tcmu_runner_handler_called after restart
- name: set _tcmu_runner_handler_called after restart
set_fact:
_tcmu_runner_handler_called: False
listen: "restart ceph tcmu-runner"
- name: set _rbd_target_gw_handler_called before restart
- name: set _rbd_target_gw_handler_called before restart
set_fact:
_rbd_target_gw_handler_called: True
listen: "restart ceph rbd-target-gw"
- name: copy rbd-target-gw restart script
- name: copy rbd-target-gw restart script
template:
src: restart_rbd_target_gw.sh.j2
dest: /tmp/restart_rbd_target_gw.sh
......@@ -412,7 +416,7 @@
when:
- iscsi_gw_group_name in group_names
- name: restart rbd-target-gw
- name: restart rbd-target-gw
command: /usr/bin/env bash /tmp/restart_rbd_target_gw.sh
listen: "restart ceph rbd-target-gw"
when:
......@@ -424,17 +428,17 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _rbd_target_gw_handler_called after restart
- name: set _rbd_target_gw_handler_called after restart
set_fact:
_rbd_target_gw_handler_called: False
listen: "restart ceph rbd-target-gw"
- name: set _rbd_target_api_handler_called before restart
- name: set _rbd_target_api_handler_called before restart
set_fact:
_rbd_target_api_handler_called: True
listen: "restart ceph rbd-target-api"
- name: copy rbd-target-api restart script
- name: copy rbd-target-api restart script
template:
src: restart_rbd_target_api.sh.j2
dest: /tmp/restart_rbd_target_api.sh
......@@ -445,7 +449,7 @@
when:
- iscsi_gw_group_name in group_names
- name: restart rbd-target-api
- name: restart rbd-target-api
command: /usr/bin/env bash /tmp/restart_rbd_target_api.sh
listen: "restart ceph rbd-target-api"
when:
......@@ -457,7 +461,7 @@
delegate_to: "{{ item }}"
run_once: True
- name: set _rbd_target_api_handler_called after restart
- name: set _rbd_target_api_handler_called after restart
set_fact:
_rbd_target_api_handler_called: False
listen: "restart ceph rbd-target-api"
---
- name: generate systemd unit files for tcmu-runner, rbd-target-api and rbd-target-gw
become: true
template:
src: "{{ role_path }}/templates/{{ item }}.service.j2"
dest: /etc/systemd/system/{{ item }}.service
owner: "root"
group: "root"
mode: "0644"
with_items:
- tcmu-runner
- rbd-target-gw
- rbd-target-api
notify:
- restart ceph {{ item }}
- name: include systemd.yml
include_tasks: systemd.yml
- name: systemd start tcmu-runner, rbd-target-api and rbd-target-gw containers
systemd:
......
---
- name: generate systemd unit files for tcmu-runner, rbd-target-api and rbd-target-gw
become: true
template:
src: "{{ role_path }}/templates/{{ item }}.service.j2"
dest: /etc/systemd/system/{{ item }}.service
owner: "root"
group: "root"
mode: "0644"
with_items:
- tcmu-runner
- rbd-target-gw
- rbd-target-api
notify:
- restart ceph {{ item }}
\ No newline at end of file
container/systemd.yml
\ No newline at end of file
[Unit]
Description=RBD Target API Service
{% if container_binary == 'docker' %}
After=docker.service
Requires=docker.service
{% else %}