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: ...@@ -555,6 +555,7 @@ dummy:
########## ##########
# DOCKER # # DOCKER #
########## ##########
#container_binary: docker
#docker_exec_cmd: #docker_exec_cmd:
#docker: false #docker: false
#ceph_docker_image: "ceph/daemon" #ceph_docker_image: "ceph/daemon"
......
...@@ -555,6 +555,7 @@ ceph_rhcs_version: 3 ...@@ -555,6 +555,7 @@ ceph_rhcs_version: 3
########## ##########
# DOCKER # # DOCKER #
########## ##########
#container_binary: docker
#docker_exec_cmd: #docker_exec_cmd:
#docker: false #docker: false
ceph_docker_image: "rhceph/rhceph-3-rhel7" 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 ...@@ -547,6 +547,7 @@ ceph_tcmalloc_max_total_thread_cache: 0
########## ##########
# DOCKER # # DOCKER #
########## ##########
container_binary: docker
docker_exec_cmd: docker_exec_cmd:
docker: false docker: false
ceph_docker_image: "ceph/daemon" 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 @@ ...@@ -23,15 +23,8 @@
when: when:
- mon_use_fqdn - mon_use_fqdn
- name: get docker version - name: include ceph_docker_version.yml
command: docker --version include_tasks: ceph_docker_version.yml
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] }}"
# Only include 'checks.yml' when : # Only include 'checks.yml' when :
# we are deploying containers without kv AND host is either a mon OR a nfs OR an osd, # we are deploying containers without kv AND host is either a mon OR a nfs OR an osd,
......
This diff is collapsed.
--- ---
- name: generate systemd unit files for tcmu-runner, rbd-target-api and rbd-target-gw - name: include systemd.yml
become: true include_tasks: systemd.yml
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: systemd start tcmu-runner, rbd-target-api and rbd-target-gw containers - name: systemd start tcmu-runner, rbd-target-api and rbd-target-gw containers
systemd: 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] [Unit]
Description=RBD Target API Service Description=RBD Target API Service
{% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
{% else %}
After=network.target
{% endif %}
[Service] [Service]
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/docker stop rbd-target-api ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-api
ExecStartPre=-/usr/bin/docker rm rbd-target-api ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-api
ExecStart=/usr/bin/docker run --rm \ ExecStart=/usr/bin/{{ container_binary }} run --rm \
--memory={{ ceph_rbd_target_api_docker_memory_limit }} \ --memory={{ ceph_rbd_target_api_docker_memory_limit }} \
{% if ceph_docker_version.split('.')[0] is version_compare('13', '>=') -%} {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version_compare('13', '>=')) or container_binary == 'podman' -%}
--cpus={{ ceph_rbd_target_api_docker_cpu_limit }} \ --cpus={{ ceph_rbd_target_api_docker_cpu_limit }} \
{% else -%} {% else -%}
--cpu-quota={{ ceph_rbd_target_api_docker_cpu_limit * 100000 }} \ --cpu-quota={{ ceph_rbd_target_api_docker_cpu_limit * 100000 }} \
...@@ -25,7 +29,7 @@ ExecStart=/usr/bin/docker run --rm \ ...@@ -25,7 +29,7 @@ ExecStart=/usr/bin/docker run --rm \
-e CEPH_DAEMON=RBD_TARGET_API \ -e CEPH_DAEMON=RBD_TARGET_API \
--name=rbd-target-api \ --name=rbd-target-api \
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
ExecStopPost=-/usr/bin/docker stop rbd-target-api ExecStopPost=-/usr/bin/{{ container_binary }} stop rbd-target-api
Restart=always Restart=always
RestartSec=10s RestartSec=10s
TimeoutStartSec=120 TimeoutStartSec=120
......
[Unit] [Unit]
Description=RBD Target Gateway Service Description=RBD Target Gateway Service
{% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
{% else %}
After=network.target
{% endif %}
[Service] [Service]
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/docker stop rbd-target-gw ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-gw
ExecStartPre=-/usr/bin/docker rm rbd-target-gw ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-gw
ExecStart=/usr/bin/docker run --rm \ ExecStart=/usr/bin/{{ container_binary }} run --rm \
--memory={{ ceph_rbd_target_gw_docker_memory_limit }} \ --memory={{ ceph_rbd_target_gw_docker_memory_limit }} \
{% if ceph_docker_version.split('.')[0] is version_compare('13', '>=') -%} {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version_compare('13', '>=')) or container_binary == 'podman' -%}
--cpus={{ ceph_rbd_target_gw_docker_cpu_limit }} \ --cpus={{ ceph_rbd_target_gw_docker_cpu_limit }} \
{% else -%} {% else -%}
--cpu-quota={{ ceph_rbd_target_gw_docker_cpu_limit * 100000 }} \ --cpu-quota={{ ceph_rbd_target_gw_docker_cpu_limit * 100000 }} \
...@@ -25,7 +29,8 @@ ExecStart=/usr/bin/docker run --rm \ ...@@ -25,7 +29,8 @@ ExecStart=/usr/bin/docker run --rm \
-e CEPH_DAEMON=RBD_TARGET_GW \ -e CEPH_DAEMON=RBD_TARGET_GW \
--name=rbd-target-gw \ --name=rbd-target-gw \
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
ExecStopPost=-/usr/bin/docker stop rbd-target-gw ExecStopPost=-/usr/bin/{{ container_binary }} stop rbd-target-gw
KillMode=none
Restart=always Restart=always
RestartSec=10s RestartSec=10s
TimeoutStartSec=120 TimeoutStartSec=120
......
[Unit] [Unit]
Description=TCMU Runner Description=TCMU Runner
{% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
{% else %}
After=network.target
{% endif %}
[Service] [Service]
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/docker stop tcmu-runner ExecStartPre=-/usr/bin/{{ container_binary }} stop tcmu-runner
ExecStartPre=-/usr/bin/docker rm tcmu-runner ExecStartPre=-/usr/bin/{{ container_binary }} rm tcmu-runner
ExecStart=/usr/bin/docker run --rm \ ExecStart=/usr/bin/{{ container_binary }} run --rm \
--memory={{ ceph_tcmu_runner_docker_memory_limit }} \ --memory={{ ceph_tcmu_runner_docker_memory_limit }} \
{% if ceph_docker_version.split('.')[0] is version_compare('13', '>=') -%} {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version_compare('13', '>=')) or container_binary == 'podman' -%}
--cpus={{ ceph_tcmu_runner_docker_cpu_limit }} \ --cpus={{ ceph_tcmu_runner_docker_cpu_limit }} \
{% else -%} {% else -%}
--cpu-quota={{ ceph_tcmu_runner_docker_cpu_limit * 100000 }} \ --cpu-quota={{ ceph_tcmu_runner_docker_cpu_limit * 100000 }} \
...@@ -25,7 +29,7 @@ ExecStart=/usr/bin/docker run --rm \ ...@@ -25,7 +29,7 @@ ExecStart=/usr/bin/docker run --rm \
-e CEPH_DAEMON=TCMU_RUNNER \ -e CEPH_DAEMON=TCMU_RUNNER \
--name=tcmu-runner \ --name=tcmu-runner \
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
ExecStopPost=-/usr/bin/docker stop tcmu-runner ExecStopPost=-/usr/bin/{{ container_binary }} stop tcmu-runner
Restart=always Restart=always
RestartSec=10s RestartSec=10s
TimeoutStartSec=120 TimeoutStartSec=120
......
...@@ -45,16 +45,8 @@ ...@@ -45,16 +45,8 @@
- "{{ statconfig.results }}" - "{{ statconfig.results }}"
when: item.1.stat.exists == true when: item.1.stat.exists == true
- name: generate systemd unit file - name: include systemd.yml
become: true include_tasks: systemd.yml
template:
src: "{{ role_path }}/templates/ceph-mds.service.j2"
dest: /etc/systemd/system/ceph-mds@.service
owner: "root"
group: "root"
mode: "0644"
notify:
- restart ceph mdss
- name: systemd start mds container - name: systemd start mds container
systemd: systemd:
......
---
- name: generate systemd unit file
become: true
template:
src: "{{ role_path }}/templates/ceph-mds.service.j2"
dest: /etc/systemd/system/ceph-mds@.service
owner: "root"
group: "root"
mode: "0644"
notify:
- restart ceph mdss
[Unit] [Unit]
Description=Ceph MDS Description=Ceph MDS
{% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
{% else %}
After=network.target
{% endif %}
{% set cpu_limit = ansible_processor_vcpus|int if ceph_mds_docker_cpu_limit|int > ansible_processor_vcpus|int else ceph_mds_docker_cpu_limit|int %} {% set cpu_limit = ansible_processor_vcpus|int if ceph_mds_docker_cpu_limit|int > ansible_processor_vcpus|int else ceph_mds_docker_cpu_limit|int %}
[Service] [Service]
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/docker stop ceph-mds-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/docker rm ceph-mds-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mds-{{ ansible_hostname }}
ExecStart=/usr/bin/docker run --rm --net=host \ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \
--memory={{ ceph_mds_docker_memory_limit }} \ --memory={{ ceph_mds_docker_memory_limit }} \
{% if ceph_docker_version.split('.')[0] is version_compare('13', '>=') -%} {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version_compare('13', '>=')) or container_binary == 'podman' -%}
--cpus={{ cpu_limit }} \ --cpus={{ cpu_limit }} \
{% else -%} {% else -%}
--cpu-quota={{ cpu_limit * 100000 }} \ --cpu-quota={{ cpu_limit * 100000 }} \
...@@ -30,7 +34,7 @@ ExecStart=/usr/bin/docker run --rm --net=host \ ...@@ -30,7 +34,7 @@ ExecStart=/usr/bin/docker run --rm --net=host \
{{ ceph_mds_docker_extra_env }} \ {{ ceph_mds_docker_extra_env }} \
--name=ceph-mds-{{ ansible_hostname }} \ --name=ceph-mds-{{ ansible_hostname }} \
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
ExecStopPost=-/usr/bin/docker stop ceph-mds-{{ ansible_hostname }} ExecStopPost=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }}
Restart=always Restart=always
RestartSec=10s RestartSec=10s
TimeoutStartSec=120 TimeoutStartSec=120
......
--- ---
- name: generate systemd unit file - name: include systemd.yml
become: true include_tasks: systemd.yml
template:
src: "{{ role_path }}/templates/ceph-mgr.service.j2"
dest: /etc/systemd/system/ceph-mgr@.service
owner: "root"
group: "root"
mode: "0644"
notify:
- restart ceph mgrs
- name: systemd start mgr container - name: systemd start mgr container
systemd: systemd:
......
---
- name: generate systemd unit file
become: true
template:
src: "{{ role_path }}/templates/ceph-mgr.service.j2"
dest: /etc/systemd/system/ceph-mgr@.service
owner: "root"
group: "root"
mode: "0644"
notify:
- restart ceph mgrs
docker/systemd.yml
\ No newline at end of file
[Unit] [Unit]
Description=Ceph Manager Description=Ceph Manager
{% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
{% else %}
After=network.target
{% endif %}
[Service] [Service]
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/docker stop ceph-mgr-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/docker rm ceph-mgr-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mgr-{{ ansible_hostname }}
ExecStart=/usr/bin/docker run --rm --net=host \ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \
--memory={{ ceph_mgr_docker_memory_limit }} \ --memory={{ ceph_mgr_docker_memory_limit }} \
{% if ceph_docker_version.split('.')[0] is version_compare('13', '>=') -%} {% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version_compare('13', '>=')) or container_binary == 'podman' -%}
--cpus={{ ceph_mgr_docker_cpu_limit }} \ --cpus={{ ceph_mgr_docker_cpu_limit }} \
{% else -%} {% else -%}
--cpu-quota={{ ceph_mgr_docker_cpu_limit * 100000 }} \ --cpu-quota={{ ceph_mgr_docker_cpu_limit * 100000 }} \
...@@ -29,7 +33,7 @@ ExecStart=/usr/bin/docker run --rm --net=host \ ...@@ -29,7 +33,7 @@ ExecStart=/usr/bin/docker run --rm --net=host \
{{ ceph_mgr_docker_extra_env }} \ {{ ceph_mgr_docker_extra_env }} \
--name=ceph-mgr-{{ ansible_hostname }} \ --name=ceph-mgr-{{ ansible_hostname }} \
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
ExecStopPost=-/usr/bin/docker stop ceph-mgr-{{ ansible_hostname }} ExecStopPost=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }}
Restart=always Restart=always
RestartSec=10s RestartSec=10s
TimeoutStartSec=120 TimeoutStartSec=120
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment