Merge pull request #1267 from ceph/container-systemd

Container systemd
pull/1283/head
Sébastien Han 2017-02-03 14:02:53 +01:00 committed by GitHub
commit 55abf69481
10 changed files with 25 additions and 41 deletions

View File

@ -0,0 +1,2 @@
---
- include: system_checks.yml

View File

@ -0,0 +1,5 @@
---
- name: fail if systemd is not present
fail:
msg: "Systemd must be present"
when: ansible_service_mgr != 'systemd'

View File

@ -8,26 +8,22 @@
owner: "root" owner: "root"
group: "root" group: "root"
mode: "0644" mode: "0644"
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: link systemd unit file for mds instance - name: link systemd unit file for mds instance
file: file:
src: /var/lib/ceph/ceph-mds@.service src: /var/lib/ceph/ceph-mds@.service
dest: /etc/systemd/system/multi-user.target.wants/ceph-mds@{{ ansible_hostname }}.service dest: /etc/systemd/system/multi-user.target.wants/ceph-mds@{{ ansible_hostname }}.service
state: link state: link
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: enable systemd unit file for mds instance - name: enable systemd unit file for mds instance
command: systemctl enable /etc/systemd/system/multi-user.target.wants/ceph-mds@{{ ansible_hostname }}.service command: systemctl enable /etc/systemd/system/multi-user.target.wants/ceph-mds@{{ ansible_hostname }}.service
failed_when: false failed_when: false
changed_when: false changed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: reload systemd unit files - name: reload systemd unit files
command: systemctl daemon-reload command: systemctl daemon-reload
changed_when: false changed_when: false
failed_when: false failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: systemd start mds container - name: systemd start mds container
service: service:

View File

@ -62,21 +62,29 @@
- include: start_docker_monitor.yml - include: start_docker_monitor.yml
# NOTE: if we don't wait we will attempt to copy config to ansible host - name: wait for monitor socket to exist
# before admin key is ready, preventing future daemons e.g. ceph-mds from command: docker exec {{ ansible_hostname }} stat /var/run/ceph/{{ cluster }}-mon.{{ ansible_hostname }}.asok
# properly retrieving key register: monitor_socket
- name: "wait for {{ cluster }}.client.admin.keyring exists" retries: 5
wait_for: delay: 10
path: /etc/ceph/{{ cluster }}.client.admin.keyring until: monitor_socket.rc == 0
when: cephx
- name: force peer addition as potential bootstrap peer for cluster bringup
command: docker exec {{ ansible_hostname }} ceph --admin-daemon /var/run/ceph/{{ cluster }}-mon.{{ ansible_hostname }}.asok add_bootstrap_peer_hint {{ hostvars[item]['ansible_' + ceph_mon_docker_interface].ipv4.address }}
with_items: "{{ groups.mons }}"
changed_when: false
failed_when: false
when:
- inventory_hostname == groups.mons[0]
- not mon_containerized_deployment_with_kv
- include: copy_configs.yml - include: copy_configs.yml
when: not mon_containerized_deployment_with_kv when: not mon_containerized_deployment_with_kv
- name: create ceph rest api keyring when mon is containerized - name: create ceph rest api keyring when mon is containerized
command: docker exec {{ ansible_hostname }} ceph auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/ceph.client.restapi.keyring command: docker exec {{ ansible_hostname }} ceph --cluster {{ cluster }} auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/{{ cluster }}.client.restapi.keyring
args: args:
creates: /etc/ceph/ceph.client.restapi.keyring creates: /etc/ceph/{{ cluster }}.client.restapi.keyring
changed_when: false changed_when: false
when: when:
- cephx - cephx

View File

@ -40,7 +40,6 @@
image: "{{ ceph_mon_docker_username }}/{{ ceph_mon_docker_imagename }}:{{ ceph_mon_docker_image_tag }}" image: "{{ ceph_mon_docker_username }}/{{ ceph_mon_docker_imagename }}:{{ ceph_mon_docker_image_tag }}"
when: mon_containerized_deployment_with_kv when: mon_containerized_deployment_with_kv
# Use systemd to manage container on Atomic host and CoreOS
- name: generate systemd unit file - name: generate systemd unit file
become: true become: true
template: template:
@ -49,19 +48,16 @@
owner: "root" owner: "root"
group: "root" group: "root"
mode: "0644" mode: "0644"
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: enable systemd unit file for mon instance - name: enable systemd unit file for mon instance
shell: systemctl enable ceph-mon@{{ ansible_hostname }}.service shell: systemctl enable ceph-mon@{{ ansible_hostname }}.service
failed_when: false failed_when: false
changed_when: false changed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: reload systemd unit files - name: reload systemd unit files
shell: systemctl daemon-reload shell: systemctl daemon-reload
changed_when: false changed_when: false
failed_when: false failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: systemd start mon container - name: systemd start mon container
service: service:

View File

@ -5,7 +5,7 @@ After=docker.service
[Service] [Service]
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/docker rm %i ExecStartPre=-/usr/bin/docker rm %i
ExecStartPre=/usr/bin/mkdir -p /etc/ceph /var/lib/ceph/mon ExecStartPre=$(command -v mkdir) -p /etc/ceph /var/lib/ceph/mon
ExecStart=/usr/bin/docker run --rm --name %i --net=host \ ExecStart=/usr/bin/docker run --rm --name %i --net=host \
{% if not mon_containerized_deployment_with_kv -%} {% if not mon_containerized_deployment_with_kv -%}
-v /var/lib/ceph:/var/lib/ceph \ -v /var/lib/ceph:/var/lib/ceph \

View File

@ -8,34 +8,22 @@
owner: "root" owner: "root"
group: "root" group: "root"
mode: "0644" mode: "0644"
when:
is_atomic or
ansible_os_family == 'CoreOS'
- name: link systemd unit file for NFS instance - name: link systemd unit file for NFS instance
file: file:
src: /var/lib/nfs/ganesha/ceph-nfs@.service src: /var/lib/nfs/ganesha/ceph-nfs@.service
dest: /etc/systemd/system/multi-user.target.wants/ceph-nfs@{{ ansible_hostname }}.service dest: /etc/systemd/system/multi-user.target.wants/ceph-nfs@{{ ansible_hostname }}.service
state: link state: link
when:
is_atomic or
ansible_os_family == 'CoreOS'
- name: enable systemd unit file for NFS instance - name: enable systemd unit file for NFS instance
shell: systemctl enable /etc/systemd/system/multi-user.target.wants/ceph-nfs@{{ ansible_hostname }}.service shell: systemctl enable /etc/systemd/system/multi-user.target.wants/ceph-nfs@{{ ansible_hostname }}.service
failed_when: false failed_when: false
changed_when: false changed_when: false
when:
is_atomic or
ansible_os_family == 'CoreOS'
- name: reload systemd unit files - name: reload systemd unit files
shell: systemctl daemon-reload shell: systemctl daemon-reload
changed_when: false changed_when: false
failed_when: false failed_when: false
when:
is_atomic or
ansible_os_family == 'CoreOS'
- name: systemd start NFS container - name: systemd start NFS container
service: service:

View File

@ -67,7 +67,6 @@
- ceph_osd_docker_prepare_env is defined - ceph_osd_docker_prepare_env is defined
- osd_containerized_deployment_with_kv - osd_containerized_deployment_with_kv
# Use systemd to manage container on appropriate host
- name: generate systemd unit file - name: generate systemd unit file
become: true become: true
template: template:
@ -77,20 +76,17 @@
group: "root" group: "root"
mode: "0644" mode: "0644"
failed_when: false failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: enable systemd unit file for osd instance - name: enable systemd unit file for osd instance
shell: systemctl enable ceph-osd@{{ item | basename }}.service shell: systemctl enable ceph-osd@{{ item | basename }}.service
failed_when: false failed_when: false
changed_when: false changed_when: false
with_items: "{{ ceph_osd_docker_devices }}" with_items: "{{ ceph_osd_docker_devices }}"
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: reload systemd unit files - name: reload systemd unit files
shell: systemctl daemon-reload shell: systemctl daemon-reload
changed_when: false changed_when: false
failed_when: false failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: systemd start osd container - name: systemd start osd container
service: service:

View File

@ -8,19 +8,16 @@
owner: "root" owner: "root"
group: "root" group: "root"
mode: "0644" mode: "0644"
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: enable systemd unit file for rbd mirror instance - name: enable systemd unit file for rbd mirror instance
command: systemctl enable ceph-rbd-mirror@{{ ansible_hostname }}.service command: systemctl enable ceph-rbd-mirror@{{ ansible_hostname }}.service
failed_when: false failed_when: false
changed_when: false changed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: reload systemd unit files - name: reload systemd unit files
command: systemctl daemon-reload command: systemctl daemon-reload
changed_when: false changed_when: false
failed_when: false failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: systemd start rbd mirror container - name: systemd start rbd mirror container
service: service:

View File

@ -8,26 +8,22 @@
owner: "root" owner: "root"
group: "root" group: "root"
mode: "0644" mode: "0644"
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: link systemd unit file for rgw instance - name: link systemd unit file for rgw instance
file: file:
src: /var/lib/ceph/ceph-rgw@.service src: /var/lib/ceph/ceph-rgw@.service
dest: /etc/systemd/system/multi-user.target.wants/ceph-rgw@{{ ansible_hostname }}.service dest: /etc/systemd/system/multi-user.target.wants/ceph-rgw@{{ ansible_hostname }}.service
state: link state: link
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: enable systemd unit file for rgw instance - name: enable systemd unit file for rgw instance
shell: systemctl enable /etc/systemd/system/multi-user.target.wants/ceph-rgw@{{ ansible_hostname }}.service shell: systemctl enable /etc/systemd/system/multi-user.target.wants/ceph-rgw@{{ ansible_hostname }}.service
failed_when: false failed_when: false
changed_when: false changed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: reload systemd unit files - name: reload systemd unit files
shell: systemctl daemon-reload shell: systemctl daemon-reload
changed_when: false changed_when: false
failed_when: false failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: systemd start rgw container - name: systemd start rgw container
service: service: