containers: introduce target systemd unit

This adds ceph-*.target systemd unit files support for containerized
deployments.
This also fixes a regression introduced by PR #6719 (rgw and nfs systemd
units not getting purged)

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

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/6850/head
Guillaume Abrioux 2021-08-10 15:21:19 +02:00 committed by Dimitri Savineau
parent 3d27f9e7dc
commit 09ef465f62
25 changed files with 239 additions and 82 deletions

View File

@ -380,17 +380,14 @@
failed_when: false failed_when: false
when: containerized_deployment | bool when: containerized_deployment | bool
- name: remove ceph-mon systemd unit file - name: remove ceph-mon systemd files
file: file:
path: /etc/systemd/system/ceph-mon@.service path: "{{ item }}"
state: absent state: absent
when: containerized_deployment | bool loop:
- /etc/systemd/system/ceph-mon@.service
- name: remove ceph-mon systemd override directory - /etc/systemd/system/ceph-mon@.service.d
file: - /etc/systemd/system/ceph-mon.target
path: /etc/systemd/system/ceph-mon@.service.d
state: absent
when: not containerized_deployment | bool
- name: waiting for the monitor to join the quorum... - name: waiting for the monitor to join the quorum...
command: "{{ cephadm_cmd }} shell --fsid {{ fsid }} -- ceph --cluster {{ cluster }} quorum_status --format json" command: "{{ cephadm_cmd }} shell --fsid {{ fsid }} -- ceph --cluster {{ cluster }} quorum_status --format json"
@ -428,17 +425,15 @@
failed_when: false failed_when: false
when: containerized_deployment | bool when: containerized_deployment | bool
- name: remove ceph-mgr systemd unit file - name: remove ceph-mgr systemd files
file: file:
path: /etc/systemd/system/ceph-mgr@.service path: "{{ item }}"
state: absent state: absent
when: containerized_deployment | bool loop:
- /etc/systemd/system/ceph-mgr@.service
- /etc/systemd/system/ceph-mgr@.service.d
- /etc/systemd/system/ceph-mgr.target
- name: remove ceph-mgr systemd override directory
file:
path: /etc/systemd/system/ceph-mgr@.service.d
state: absent
when: not containerized_deployment | bool
- name: set osd flags - name: set osd flags
hosts: "{{ osd_group_name|default('osds') }}" hosts: "{{ osd_group_name|default('osds') }}"
@ -561,20 +556,15 @@
firewalld: "{{ true if configure_firewall | bool else false }}" firewalld: "{{ true if configure_firewall | bool else false }}"
loop: '{{ (osd_list.stdout | from_json).keys() | list }}' loop: '{{ (osd_list.stdout | from_json).keys() | list }}'
- name: remove ceph-osd systemd unit and ceph-osd-run.sh files - name: remove ceph-osd systemd and ceph-osd-run.sh files
file: file:
path: '{{ item }}' path: "{{ item }}"
state: absent state: absent
loop: loop:
- /etc/systemd/system/ceph-osd@.service - /etc/systemd/system/ceph-osd@.service
- /etc/systemd/system/ceph-osd@.service.d
- /etc/systemd/system/ceph-osd.target
- "{{ ceph_osd_docker_run_script_path | default('/usr/share') }}/ceph-osd-run.sh" - "{{ ceph_osd_docker_run_script_path | default('/usr/share') }}/ceph-osd-run.sh"
when: containerized_deployment | bool
- name: remove ceph-osd systemd override directory
file:
path: /etc/systemd/system/ceph-osd@.service.d
state: absent
when: not containerized_deployment | bool
- name: remove osd directory - name: remove osd directory
file: file:
@ -680,7 +670,7 @@
name: ceph-mds.target name: ceph-mds.target
state: stopped state: stopped
enabled: false enabled: false
when: not containerized_deployment | bool failed_when: false
- name: reset failed ceph-mds systemd unit - name: reset failed ceph-mds systemd unit
command: "systemctl reset-failed ceph-mds@{{ ansible_facts['hostname'] }}" # noqa 303 command: "systemctl reset-failed ceph-mds@{{ ansible_facts['hostname'] }}" # noqa 303
@ -688,17 +678,14 @@
failed_when: false failed_when: false
when: containerized_deployment | bool when: containerized_deployment | bool
- name: remove ceph-mds systemd unit file - name: remove ceph-mds systemd files
file: file:
path: /etc/systemd/system/ceph-mds@.service path: "{{ item }}"
state: absent state: absent
when: containerized_deployment | bool loop:
- /etc/systemd/system/ceph-mds@.service
- name: remove ceph-mds systemd override directory - /etc/systemd/system/ceph-mds@.service.d
file: - /etc/systemd/system/ceph-mds.target
path: /etc/systemd/system/ceph-mds@.service.d
state: absent
when: not containerized_deployment | bool
- name: remove legacy ceph mds data - name: remove legacy ceph mds data
file: file:
@ -805,10 +792,10 @@
- name: stop and disable ceph-radosgw systemd target - name: stop and disable ceph-radosgw systemd target
service: service:
name: ceph-rgw.target name: ceph-radosgw.target
state: stopped state: stopped
enabled: false enabled: false
when: not containerized_deployment | bool failed_when: false
- name: reset failed ceph-radosgw systemd unit - name: reset failed ceph-radosgw systemd unit
command: "systemctl reset-failed ceph-radosgw@rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}" # noqa 303 command: "systemctl reset-failed ceph-radosgw@rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}" # noqa 303
@ -817,17 +804,14 @@
loop: '{{ rgw_instances }}' loop: '{{ rgw_instances }}'
when: containerized_deployment | bool when: containerized_deployment | bool
- name: remove ceph-radosgw systemd unit file - name: remove ceph-radosgw systemd files
file: file:
path: /etc/systemd/system/ceph-radosgw@.service path: "{{ item }}"
state: absent state: absent
when: containerized_deployment | bool loop:
- /etc/systemd/system/ceph-radosgw@.service
- name: remove ceph-radosgw systemd override directory - /etc/systemd/system/ceph-radosgw@.service.d
file: - /etc/systemd/system/ceph-radosgw.target
path: /etc/systemd/system/ceph-radosgw@.service.d
state: absent
when: not containerized_deployment | bool
- name: remove legacy ceph radosgw data - name: remove legacy ceph radosgw data
file: file:
@ -874,17 +858,13 @@
failed_when: false failed_when: false
when: containerized_deployment | bool when: containerized_deployment | bool
- name: remove ceph-nfs systemd unit file - name: remove ceph-nfs systemd unit files
file: file:
path: /etc/systemd/system/ceph-nfs@.service path: "{{ item }}"
state: absent state: absent
when: containerized_deployment | bool loop:
- /etc/systemd/system/ceph-nfs@.service
- name: remove ceph-nfs systemd override directory - /etc/systemd/system/ceph-nfs@.service.d
file:
path: /etc/systemd/system/ceph-nfs@.service.d
state: absent
when: not containerized_deployment | bool
- name: remove legacy ceph radosgw directory - name: remove legacy ceph radosgw directory
file: file:
@ -1020,7 +1000,7 @@
name: ceph-rbd-mirror.target name: ceph-rbd-mirror.target
state: stopped state: stopped
enabled: false enabled: false
when: not containerized_deployment | bool failed_when: false
- name: reset failed rbd-mirror systemd unit - name: reset failed rbd-mirror systemd unit
command: "systemctl reset-failed ceph-rbd-mirror@rbd-mirror.{{ ansible_facts['hostname'] }}" # noqa 303 command: "systemctl reset-failed ceph-rbd-mirror@rbd-mirror.{{ ansible_facts['hostname'] }}" # noqa 303
@ -1028,17 +1008,15 @@
failed_when: false failed_when: false
when: containerized_deployment | bool when: containerized_deployment | bool
- name: remove rbd-mirror systemd unit file - name: remove rbd-mirror systemd files
file: file:
path: /etc/systemd/system/ceph-rbd-mirror@.service path: "{{ item }}"
state: absent state: absent
when: containerized_deployment | bool loop:
- /etc/systemd/system/ceph-rbd-mirror@.service
- /etc/systemd/system/ceph-rbd-mirror@.service.d
- /etc/systemd/system/ceph-rbd-mirror.target
- name: remove rbd-mirror systemd override directory
file:
path: /etc/systemd/system/ceph-rbd-mirror@.service.d
state: absent
when: not containerized_deployment | bool
- name: redeploy iscsigw daemons - name: redeploy iscsigw daemons
hosts: "{{ iscsi_gw_group_name|default('iscsigws') }}" hosts: "{{ iscsi_gw_group_name|default('iscsigws') }}"
@ -1098,6 +1076,7 @@
- tcmu-runner - tcmu-runner
when: containerized_deployment | bool when: containerized_deployment | bool
- name: redeploy ceph-crash daemons - name: redeploy ceph-crash daemons
hosts: hosts:
- "{{ mon_group_name|default('mons') }}" - "{{ mon_group_name|default('mons') }}"
@ -1120,6 +1099,11 @@
enabled: false enabled: false
failed_when: false failed_when: false
- name: remove ceph-crash systemd unit file
file:
path: /etc/systemd/system/ceph-crash@.service
state: absent
- name: update the placement of ceph-crash hosts - name: update the placement of ceph-crash hosts
command: "{{ cephadm_cmd }} shell --fsid {{ fsid }} -- ceph --cluster {{ cluster }} orch apply crash --placement='label:ceph'" command: "{{ cephadm_cmd }} shell --fsid {{ fsid }} -- ceph --cluster {{ cluster }} orch apply crash --placement='label:ceph'"
run_once: true run_once: true
@ -1128,6 +1112,7 @@
environment: environment:
CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}' CEPHADM_IMAGE: '{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'
- name: redeploy alertmanager/grafana/prometheus daemons - name: redeploy alertmanager/grafana/prometheus daemons
hosts: "{{ monitoring_group_name|default('monitoring') }}" hosts: "{{ monitoring_group_name|default('monitoring') }}"
serial: 1 serial: 1

View File

@ -248,8 +248,11 @@
- name: remove ceph mds service - name: remove ceph mds service
file: file:
path: /etc/systemd/system/ceph-mds@.service path: /etc/systemd/system/ceph-mds{{ item }}
state: absent state: absent
loop:
- '@.service'
- '.target'
- name: purge ceph mgr cluster - name: purge ceph mgr cluster
@ -267,9 +270,11 @@
- name: remove ceph mgr service - name: remove ceph mgr service
file: file:
path: /etc/systemd/system/ceph-mgr@.service path: /etc/systemd/system/ceph-mgr{{ item }}
state: absent state: absent
loop:
- '@.service'
- '.target'
- name: purge rgwloadbalancer cluster - name: purge rgwloadbalancer cluster
hosts: rgwloadbalancers hosts: rgwloadbalancers
@ -304,6 +309,14 @@
failed_when: false failed_when: false
with_items: "{{ rgw_instances }}" with_items: "{{ rgw_instances }}"
- name: remove ceph rgw service
file:
path: /etc/systemd/system/ceph-radosgw{{ item }}
state: absent
loop:
- '@.service'
- '.target'
- name: purge ceph rbd-mirror cluster - name: purge ceph rbd-mirror cluster
hosts: rbdmirrors hosts: rbdmirrors
@ -317,6 +330,14 @@
enabled: no enabled: no
failed_when: false failed_when: false
- name: remove ceph rbd-mirror service
file:
path: /etc/systemd/system/ceph-rbd-mirror{{ item }}
state: absent
loop:
- '@.service'
- '.target'
- name: purge ceph osd cluster - name: purge ceph osd cluster
vars: vars:
@ -599,9 +620,11 @@
- name: remove ceph osd service - name: remove ceph osd service
file: file:
path: /etc/systemd/system/ceph-osd@.service path: /etc/systemd/system/ceph-osd{{ item }}
state: absent state: absent
when: containerized_deployment | bool loop:
- '@.service'
- '.target'
- name: purge ceph mon cluster - name: purge ceph mon cluster
hosts: mons hosts: mons
@ -633,11 +656,9 @@
- name: remove ceph mon and mgr service - name: remove ceph mon and mgr service
file: file:
path: "/etc/systemd/system/ceph-{{ item }}@.service" path: "/etc/systemd/system/ceph-{{ item.0 }}{{ item.1 }}"
state: absent state: absent
with_items: loop: "{{ ['mon', 'mgr'] | product(['@.service', '.target']) | list }}"
- mon
- mgr
- name: purge ceph-crash daemons - name: purge ceph-crash daemons

View File

@ -0,0 +1,5 @@
[Unit]
Description=ceph target allowing to start/stop all ceph*@.service instances at once
[Install]
WantedBy=multi-user.target

View File

@ -1,4 +1,15 @@
--- ---
- name: generate systemd ceph-mon target file
copy:
src: ceph.target
dest: /etc/systemd/system/ceph.target
- name: enable ceph.target
service:
name: ceph.target
enabled: yes
daemon_reload: yes
- name: include prerequisites.yml - name: include prerequisites.yml
include_tasks: prerequisites.yml include_tasks: prerequisites.yml

View File

@ -41,4 +41,4 @@ TimeoutStartSec=120
TimeoutStopSec=10 TimeoutStopSec=10
[Install] [Install]
WantedBy=multi-user.target WantedBy=ceph.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-mds@.service instances at once
PartOf=ceph.target
After=ceph-mon.target
Before=ceph.target
Wants=ceph.target ceph-mon.target
[Install]
WantedBy=multi-user.target ceph.target

View File

@ -2,6 +2,13 @@
- name: include_tasks systemd.yml - name: include_tasks systemd.yml
include_tasks: systemd.yml include_tasks: systemd.yml
- name: enable ceph-mds.target
service:
name: ceph-mds.target
enabled: yes
daemon_reload: yes
when: containerized_deployment | bool
- name: systemd start mds container - name: systemd start mds container
systemd: systemd:
name: ceph-mds@{{ ansible_facts['hostname'] }} name: ceph-mds@{{ ansible_facts['hostname'] }}

View File

@ -7,3 +7,9 @@
group: "root" group: "root"
mode: "0644" mode: "0644"
notify: restart ceph mdss notify: restart ceph mdss
- name: generate systemd ceph-mds target file
copy:
src: ceph-mds.target
dest: /etc/systemd/system/ceph-mds.target
when: containerized_deployment | bool

View File

@ -1,5 +1,6 @@
[Unit] [Unit]
Description=Ceph MDS Description=Ceph MDS
PartOf=ceph-mds.target
{% if container_binary == 'docker' %} {% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
@ -53,4 +54,4 @@ PIDFile=/%t/%n-pid
{% endif %} {% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=ceph.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-mgr@.service instances at once
PartOf=ceph.target
After=ceph-mon.target
Before=ceph.target
Wants=ceph.target ceph-mon.target
[Install]
WantedBy=multi-user.target ceph.target

View File

@ -21,6 +21,13 @@
include_tasks: systemd.yml include_tasks: systemd.yml
when: containerized_deployment | bool when: containerized_deployment | bool
- name: enable ceph-mgr.target
service:
name: ceph-mgr.target
enabled: yes
daemon_reload: yes
when: containerized_deployment | bool
- name: systemd start mgr - name: systemd start mgr
systemd: systemd:
name: ceph-mgr@{{ ansible_facts['hostname'] }} name: ceph-mgr@{{ ansible_facts['hostname'] }}

View File

@ -7,3 +7,9 @@
group: "root" group: "root"
mode: "0644" mode: "0644"
notify: restart ceph mgrs notify: restart ceph mgrs
- name: generate systemd ceph-mgr target file
copy:
src: ceph-mgr.target
dest: /etc/systemd/system/ceph-mgr.target
when: containerized_deployment | bool

View File

@ -1,5 +1,6 @@
[Unit] [Unit]
Description=Ceph Manager Description=Ceph Manager
PartOf=ceph-mgr.target
{% if container_binary == 'docker' %} {% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
@ -52,4 +53,4 @@ PIDFile=/%t/%n-pid
{% endif %} {% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=ceph.target

View File

@ -0,0 +1,8 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-mon@.service instances at once
PartOf=ceph.target
Before=ceph.target
Wants=ceph.target
[Install]
WantedBy=multi-user.target ceph.target

View File

@ -7,3 +7,16 @@
group: "root" group: "root"
mode: "0644" mode: "0644"
notify: restart ceph mons notify: restart ceph mons
- name: generate systemd ceph-mon target file
copy:
src: ceph-mon.target
dest: /etc/systemd/system/ceph-mon.target
when: containerized_deployment | bool
- name: enable ceph-mon.target
service:
name: ceph-mon.target
enabled: yes
daemon_reload: yes
when: containerized_deployment | bool

View File

@ -1,5 +1,6 @@
[Unit] [Unit]
Description=Ceph Monitor Description=Ceph Monitor
PartOf=ceph-mon.target
{% if container_binary == 'docker' %} {% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
@ -67,4 +68,4 @@ PIDFile=/%t/%n-pid
{% endif %} {% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=ceph.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-osd@.service instances at once
PartOf=ceph.target
After=ceph-mon.target
Before=ceph.target
Wants=ceph.target ceph-mon.target
[Install]
WantedBy=multi-user.target ceph.target

View File

@ -7,3 +7,16 @@
group: "root" group: "root"
mode: "0644" mode: "0644"
notify: restart ceph osds notify: restart ceph osds
- name: generate systemd ceph-osd target file
copy:
src: ceph-osd.target
dest: /etc/systemd/system/ceph-osd.target
when: containerized_deployment | bool
- name: enable ceph-osd.target
service:
name: ceph-osd.target
enabled: yes
daemon_reload: yes
when: containerized_deployment | bool

View File

@ -1,6 +1,7 @@
# {{ ansible_managed }} # {{ ansible_managed }}
[Unit] [Unit]
Description=Ceph OSD Description=Ceph OSD
PartOf=ceph-osd.target
{% if container_binary == 'docker' %} {% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
@ -79,4 +80,4 @@ PIDFile=/%t/%n-pid
{% endif %} {% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=ceph.target

View File

@ -0,0 +1,7 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-rbd-mirror@.service instances at once
PartOf=ceph.target
Before=ceph.target
[Install]
WantedBy=multi-user.target ceph.target

View File

@ -7,3 +7,16 @@
group: "root" group: "root"
mode: "0644" mode: "0644"
notify: restart ceph rbdmirrors notify: restart ceph rbdmirrors
- name: generate systemd ceph-rbd-mirror target file
copy:
src: ceph-rbd-mirror.target
dest: /etc/systemd/system/ceph-rbd-mirror.target
when: containerized_deployment | bool
- name: enable ceph-rbd-mirror.target
service:
name: ceph-rbd-mirror.target
enabled: yes
daemon_reload: yes
when: containerized_deployment | bool

View File

@ -1,5 +1,6 @@
[Unit] [Unit]
Description=Ceph RBD mirror Description=Ceph RBD mirror
PartOf=ceph-rbd-mirror.target
{% if container_binary == 'docker' %} {% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
@ -52,4 +53,4 @@ PIDFile=/%t/%n-pid
{% endif %} {% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=ceph.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=ceph target allowing to start/stop all ceph-radosgw@.service instances at once
PartOf=ceph.target
After=ceph-mon.target
Before=ceph.target
Wants=ceph.target ceph-mon.target
[Install]
WantedBy=multi-user.target ceph.target

View File

@ -6,4 +6,17 @@
owner: "root" owner: "root"
group: "root" group: "root"
mode: "0644" mode: "0644"
notify: restart ceph rgws notify: restart ceph rgws
- name: generate systemd ceph-radosgw target file
copy:
src: ceph-radosgw.target
dest: /etc/systemd/system/ceph-radosgw.target
when: containerized_deployment | bool
- name: enable ceph-radosgw.target
service:
name: ceph-radosgw.target
enabled: yes
daemon_reload: yes
when: containerized_deployment | bool

View File

@ -1,5 +1,6 @@
[Unit] [Unit]
Description=Ceph RGW Description=Ceph RGW
PartOf=ceph-radosgw.target
{% if container_binary == 'docker' %} {% if container_binary == 'docker' %}
After=docker.service After=docker.service
Requires=docker.service Requires=docker.service
@ -66,4 +67,4 @@ PIDFile=/%t/%n-pid
{% endif %} {% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=ceph.target