From bd641674691bbc529711e39583e5d4bf999d84d2 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 24 Jul 2019 10:10:18 +0200 Subject: [PATCH] container: isolate systemd tasks This commit isolates the systemd unit files generation for containers into separate yml files in order to be able importing each corresponding roles without playing all tasks. This is needed so we can run ceph-ansible to render systemd unit files so they call podman instead of docker. Signed-off-by: Guillaume Abrioux --- .../tasks/container/containerized.yml | 14 +------ .../ceph-iscsi-gw/tasks/container/systemd.yml | 14 +++++++ roles/ceph-mds/tasks/containerized.yml | 11 +----- roles/ceph-mds/tasks/systemd.yml | 10 +++++ roles/ceph-mgr/tasks/start_mgr.yml | 10 +---- roles/ceph-mgr/tasks/systemd.yml | 10 +++++ roles/ceph-mon/tasks/start_monitor.yml | 10 +---- roles/ceph-mon/tasks/systemd.yml | 10 +++++ roles/ceph-nfs/tasks/start_nfs.yml | 10 +---- roles/ceph-nfs/tasks/systemd.yml | 10 +++++ roles/ceph-osd/tasks/start_osds.yml | 39 ++++++------------- roles/ceph-osd/tasks/systemd.yml | 21 ++++++++++ .../container/start_docker_rbd_mirror.yml | 10 +---- .../tasks/container/systemd.yml | 10 +++++ .../tasks/container/start_docker_rgw.yml | 10 +---- roles/ceph-rgw/tasks/container/systemd.yml | 10 +++++ 16 files changed, 120 insertions(+), 89 deletions(-) create mode 100644 roles/ceph-iscsi-gw/tasks/container/systemd.yml create mode 100644 roles/ceph-mds/tasks/systemd.yml create mode 100644 roles/ceph-mgr/tasks/systemd.yml create mode 100644 roles/ceph-mon/tasks/systemd.yml create mode 100644 roles/ceph-nfs/tasks/systemd.yml create mode 100644 roles/ceph-osd/tasks/systemd.yml create mode 100644 roles/ceph-rbd-mirror/tasks/container/systemd.yml create mode 100644 roles/ceph-rgw/tasks/container/systemd.yml diff --git a/roles/ceph-iscsi-gw/tasks/container/containerized.yml b/roles/ceph-iscsi-gw/tasks/container/containerized.yml index 014edba72..b5dc4e95d 100644 --- a/roles/ceph-iscsi-gw/tasks/container/containerized.yml +++ b/roles/ceph-iscsi-gw/tasks/container/containerized.yml @@ -7,18 +7,8 @@ - rbd-target-api - rbd-target-gw -- name: generate systemd unit files for tcmu-runner, rbd-target-api and rbd-target-gw - 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_tasks systemd.yml + include_tasks: systemd.yml - name: systemd start tcmu-runner, rbd-target-api and rbd-target-gw containers systemd: diff --git a/roles/ceph-iscsi-gw/tasks/container/systemd.yml b/roles/ceph-iscsi-gw/tasks/container/systemd.yml new file mode 100644 index 000000000..6768716b0 --- /dev/null +++ b/roles/ceph-iscsi-gw/tasks/container/systemd.yml @@ -0,0 +1,14 @@ +--- +- 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 }} diff --git a/roles/ceph-mds/tasks/containerized.yml b/roles/ceph-mds/tasks/containerized.yml index c4e64402f..e10725a46 100644 --- a/roles/ceph-mds/tasks/containerized.yml +++ b/roles/ceph-mds/tasks/containerized.yml @@ -3,15 +3,8 @@ set_fact: container_exec_cmd: "{{ container_binary }} exec ceph-mds-{{ ansible_hostname }}" -- 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 +- name: include_tasks systemd.yml + include_tasks: systemd.yml - name: systemd start mds container systemd: diff --git a/roles/ceph-mds/tasks/systemd.yml b/roles/ceph-mds/tasks/systemd.yml new file mode 100644 index 000000000..74f4d35f8 --- /dev/null +++ b/roles/ceph-mds/tasks/systemd.yml @@ -0,0 +1,10 @@ +--- +- 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 diff --git a/roles/ceph-mgr/tasks/start_mgr.yml b/roles/ceph-mgr/tasks/start_mgr.yml index 371215207..348a718dd 100644 --- a/roles/ceph-mgr/tasks/start_mgr.yml +++ b/roles/ceph-mgr/tasks/start_mgr.yml @@ -17,15 +17,9 @@ - ceph_mgr_systemd_overrides is defined - ansible_service_mgr == 'systemd' -- name: generate systemd unit file - template: - src: "{{ role_path }}/templates/ceph-mgr.service.j2" - dest: /etc/systemd/system/ceph-mgr@.service - owner: "root" - group: "root" - mode: "0644" +- name: include_tasks systemd.yml + include_tasks: systemd.yml when: containerized_deployment | bool - notify: restart ceph mgrs - name: systemd start mgr systemd: diff --git a/roles/ceph-mgr/tasks/systemd.yml b/roles/ceph-mgr/tasks/systemd.yml new file mode 100644 index 000000000..dad9d74de --- /dev/null +++ b/roles/ceph-mgr/tasks/systemd.yml @@ -0,0 +1,10 @@ +--- +- 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 diff --git a/roles/ceph-mon/tasks/start_monitor.yml b/roles/ceph-mon/tasks/start_monitor.yml index 56ef730cf..c6a4e74ea 100644 --- a/roles/ceph-mon/tasks/start_monitor.yml +++ b/roles/ceph-mon/tasks/start_monitor.yml @@ -19,14 +19,8 @@ - ceph_mon_systemd_overrides is defined - ansible_service_mgr == 'systemd' -- name: generate systemd unit file for mon container - template: - src: "{{ role_path }}/templates/ceph-mon.service.j2" - dest: /etc/systemd/system/ceph-mon@.service - owner: "root" - group: "root" - mode: "0644" - notify: restart ceph mons +- name: include_tasks systemd.yml + include_tasks: systemd.yml when: containerized_deployment | bool - name: start the monitor service diff --git a/roles/ceph-mon/tasks/systemd.yml b/roles/ceph-mon/tasks/systemd.yml new file mode 100644 index 000000000..e099ef29f --- /dev/null +++ b/roles/ceph-mon/tasks/systemd.yml @@ -0,0 +1,10 @@ +--- +- name: generate systemd unit file for mon container + become: true + template: + src: "{{ role_path }}/templates/ceph-mon.service.j2" + dest: /etc/systemd/system/ceph-mon@.service + owner: "root" + group: "root" + mode: "0644" + notify: restart ceph mons diff --git a/roles/ceph-nfs/tasks/start_nfs.yml b/roles/ceph-nfs/tasks/start_nfs.yml index bf888f070..331c993e8 100644 --- a/roles/ceph-nfs/tasks/start_nfs.yml +++ b/roles/ceph-nfs/tasks/start_nfs.yml @@ -60,15 +60,9 @@ mode: "0644" when: ceph_nfs_dynamic_exports | bool -- name: generate systemd unit file - template: - src: "{{ role_path }}/templates/ceph-nfs.service.j2" - dest: /etc/systemd/system/ceph-nfs@.service - owner: "root" - group: "root" - mode: "0644" +- name: include_tasks systemd.yml + include_tasks: systemd.yml when: containerized_deployment | bool - notify: restart ceph nfss - name: systemd start nfs container systemd: diff --git a/roles/ceph-nfs/tasks/systemd.yml b/roles/ceph-nfs/tasks/systemd.yml new file mode 100644 index 000000000..0a3185737 --- /dev/null +++ b/roles/ceph-nfs/tasks/systemd.yml @@ -0,0 +1,10 @@ +--- +- name: generate systemd unit file + become: true + template: + src: "{{ role_path }}/templates/ceph-nfs.service.j2" + dest: /etc/systemd/system/ceph-nfs@.service + owner: "root" + group: "root" + mode: "0644" + notify: restart ceph nfss \ No newline at end of file diff --git a/roles/ceph-osd/tasks/start_osds.yml b/roles/ceph-osd/tasks/start_osds.yml index b38b7071e..46e83d691 100644 --- a/roles/ceph-osd/tasks/start_osds.yml +++ b/roles/ceph-osd/tasks/start_osds.yml @@ -1,24 +1,13 @@ --- -- name: container specific tasks - when: containerized_deployment | bool - block: - - name: umount ceph disk (if on openstack) - mount: - name: /mnt - src: /dev/vdb - fstype: ext3 - state: unmounted - when: ceph_docker_on_openstack | bool - - - name: generate ceph osd docker run script - template: - src: "{{ role_path }}/templates/ceph-osd-run.sh.j2" - dest: "{{ ceph_osd_docker_run_script_path }}/ceph-osd-run.sh" - owner: "root" - group: "root" - mode: "0744" - setype: "bin_t" - notify: restart ceph osds +- name: umount ceph disk (if on openstack) + mount: + name: /mnt + src: /dev/vdb + fstype: ext3 + state: unmounted + when: + - ceph_docker_on_openstack | bool + - containerized_deployment | bool # this is for ceph-disk, the ceph-disk command is gone so we have to list /var/lib/ceph - name: get osd ids @@ -40,14 +29,8 @@ failed_when: false register: ceph_osd_ids -- name: generate systemd unit file - template: - src: "{{ role_path }}/templates/ceph-osd.service.j2" - dest: /etc/systemd/system/ceph-osd@.service - owner: "root" - group: "root" - mode: "0644" - notify: restart ceph osds +- name: include_tasks systemd.yml + include_tasks: systemd.yml when: containerized_deployment | bool - name: systemd start osd diff --git a/roles/ceph-osd/tasks/systemd.yml b/roles/ceph-osd/tasks/systemd.yml new file mode 100644 index 000000000..4992e5ee4 --- /dev/null +++ b/roles/ceph-osd/tasks/systemd.yml @@ -0,0 +1,21 @@ +--- +- name: generate ceph osd docker run script + become: true + template: + src: "{{ role_path }}/templates/ceph-osd-run.sh.j2" + dest: "{{ ceph_osd_docker_run_script_path }}/ceph-osd-run.sh" + owner: "root" + group: "root" + mode: "0744" + setype: "bin_t" + notify: restart ceph osds + +- name: generate systemd unit file + become: true + template: + src: "{{ role_path }}/templates/ceph-osd.service.j2" + dest: /etc/systemd/system/ceph-osd@.service + owner: "root" + group: "root" + mode: "0644" + notify: restart ceph osds diff --git a/roles/ceph-rbd-mirror/tasks/container/start_docker_rbd_mirror.yml b/roles/ceph-rbd-mirror/tasks/container/start_docker_rbd_mirror.yml index 36ded05ca..cebeccff4 100644 --- a/roles/ceph-rbd-mirror/tasks/container/start_docker_rbd_mirror.yml +++ b/roles/ceph-rbd-mirror/tasks/container/start_docker_rbd_mirror.yml @@ -1,13 +1,7 @@ --- # Use systemd to manage container on Atomic host -- name: generate systemd unit file - template: - src: "{{ role_path }}/templates/ceph-rbd-mirror.service.j2" - dest: /etc/systemd/system/ceph-rbd-mirror@.service - owner: "root" - group: "root" - mode: "0644" - notify: restart ceph rbdmirrors +- name: include_tasks systemd.yml + include_tasks: systemd.yml - name: systemd start rbd mirror container systemd: diff --git a/roles/ceph-rbd-mirror/tasks/container/systemd.yml b/roles/ceph-rbd-mirror/tasks/container/systemd.yml new file mode 100644 index 000000000..723c467de --- /dev/null +++ b/roles/ceph-rbd-mirror/tasks/container/systemd.yml @@ -0,0 +1,10 @@ +--- +- name: generate systemd unit file + become: true + template: + src: "{{ role_path }}/templates/ceph-rbd-mirror.service.j2" + dest: /etc/systemd/system/ceph-rbd-mirror@.service + owner: "root" + group: "root" + mode: "0644" + notify: restart ceph rbdmirrors diff --git a/roles/ceph-rgw/tasks/container/start_docker_rgw.yml b/roles/ceph-rgw/tasks/container/start_docker_rgw.yml index 0346b9687..7cb370214 100644 --- a/roles/ceph-rgw/tasks/container/start_docker_rgw.yml +++ b/roles/ceph-rgw/tasks/container/start_docker_rgw.yml @@ -10,14 +10,8 @@ INST_PORT={{ item.radosgw_frontend_port }} with_items: "{{ rgw_instances }}" -- name: generate systemd unit file - template: - src: "{{ role_path }}/templates/ceph-radosgw.service.j2" - dest: /etc/systemd/system/ceph-radosgw@.service - owner: "root" - group: "root" - mode: "0644" - notify: restart ceph rgws +- name: include_task systemd.yml + include_tasks: systemd.yml - name: systemd start rgw container systemd: diff --git a/roles/ceph-rgw/tasks/container/systemd.yml b/roles/ceph-rgw/tasks/container/systemd.yml new file mode 100644 index 000000000..1a088792b --- /dev/null +++ b/roles/ceph-rgw/tasks/container/systemd.yml @@ -0,0 +1,10 @@ +--- +- name: generate systemd unit file + become: true + template: + src: "{{ role_path }}/templates/ceph-radosgw.service.j2" + dest: /etc/systemd/system/ceph-radosgw@.service + owner: "root" + group: "root" + mode: "0644" + notify: restart ceph rgws \ No newline at end of file -- 2.39.5