2015-07-28 22:05:35 +08:00
|
|
|
---
|
2016-02-05 04:24:56 +08:00
|
|
|
# For openstack VMs modify the mount point below depending on if the Openstack
|
|
|
|
# VM deploy tool defaults to mounting ephemeral disks
|
|
|
|
- name: umount ceph disk (if on openstack)
|
2016-03-22 23:58:20 +08:00
|
|
|
mount:
|
2016-02-20 03:46:33 +08:00
|
|
|
name: /mnt
|
|
|
|
src: /dev/vdb
|
|
|
|
fstype: ext3
|
|
|
|
state: unmounted
|
2016-02-05 04:24:56 +08:00
|
|
|
when: ceph_docker_on_openstack
|
2016-03-22 23:58:20 +08:00
|
|
|
|
2016-04-01 21:40:19 +08:00
|
|
|
- name: verify if the disk was already prepared
|
|
|
|
shell: "lsblk -o PARTLABEL {{ item }} | grep -sq 'ceph'"
|
|
|
|
failed_when: false
|
2016-11-27 05:16:07 +08:00
|
|
|
always_run: true
|
2016-11-03 17:16:33 +08:00
|
|
|
with_items: "{{ ceph_osd_docker_devices }}"
|
2016-04-01 21:40:19 +08:00
|
|
|
register: osd_prepared
|
|
|
|
|
2016-05-12 23:25:12 +08:00
|
|
|
# use shell rather than docker module
|
|
|
|
# to ensure osd disk prepare finishes before
|
|
|
|
# starting the next task
|
2016-02-09 09:49:47 +08:00
|
|
|
- name: prepare ceph osd disk
|
2016-07-07 22:17:49 +08:00
|
|
|
shell: |
|
|
|
|
docker run --net=host \
|
2016-05-12 23:25:12 +08:00
|
|
|
--pid=host \
|
|
|
|
--privileged=true \
|
|
|
|
--name="{{ ansible_hostname }}-osd-prepare-{{ item.0 |
|
|
|
|
regex_replace('/', '') }}" \
|
|
|
|
-v /etc/ceph:/etc/ceph \
|
|
|
|
-v /var/lib/ceph/:/var/lib/ceph/ \
|
|
|
|
-v /dev:/dev \
|
2016-07-28 22:42:19 +08:00
|
|
|
-v /etc/localtime:/etc/localtime:ro \
|
2016-05-12 23:25:12 +08:00
|
|
|
-e "OSD_DEVICE={{ item.0 }}" \
|
2016-08-23 23:24:40 +08:00
|
|
|
-e CEPH_DAEMON=OSD_CEPH_DISK_PREPARE \
|
2016-12-15 04:22:13 +08:00
|
|
|
{{ ceph_osd_docker_prepare_env }} \
|
2017-01-17 01:39:13 +08:00
|
|
|
"{{ ceph_docker_registry }}/{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}"
|
2016-04-01 21:40:19 +08:00
|
|
|
with_together:
|
2016-11-03 17:16:33 +08:00
|
|
|
- "{{ ceph_osd_docker_devices }}"
|
|
|
|
- "{{ osd_prepared.results }}"
|
2016-04-01 18:57:58 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- item.1.get("rc", 0) != 0
|
|
|
|
- ceph_osd_docker_prepare_env is defined
|
|
|
|
- not osd_containerized_deployment_with_kv
|
2016-03-29 16:23:31 +08:00
|
|
|
|
|
|
|
- name: prepare ceph osd disk with kv_store
|
2016-06-28 19:48:46 +08:00
|
|
|
shell: |
|
2016-07-06 15:58:49 +08:00
|
|
|
docker run --net=host \
|
2016-06-28 19:48:46 +08:00
|
|
|
--pid=host \
|
|
|
|
--privileged=true \
|
|
|
|
--name="{{ ansible_hostname }}-osd-prepare-{{ item.0 |
|
|
|
|
regex_replace('/', '') }}" \
|
|
|
|
-v /dev:/dev \
|
2016-07-28 22:42:19 +08:00
|
|
|
-v /etc/localtime:/etc/localtime:ro \
|
2016-06-28 19:48:46 +08:00
|
|
|
-e "OSD_DEVICE={{ item.0 }}" \
|
|
|
|
-e "{{ ceph_osd_docker_prepare_env }}" \
|
2016-08-23 23:24:40 +08:00
|
|
|
-e CEPH_DAEMON=OSD_CEPH_DISK_PREPARE \
|
2016-06-28 19:48:46 +08:00
|
|
|
-e KV_TYPE={{kv_type}} \
|
|
|
|
-e KV_IP={{kv_endpoint}} \
|
|
|
|
-e KV_PORT={{kv_port}} \
|
2016-12-16 21:53:14 +08:00
|
|
|
{{ ceph_osd_docker_prepare_env }} \
|
2017-01-17 01:39:13 +08:00
|
|
|
"{{ ceph_docker_registry }}/{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}" \
|
2016-04-01 21:40:19 +08:00
|
|
|
with_together:
|
2016-11-03 17:16:33 +08:00
|
|
|
- "{{ ceph_osd_docker_devices }}"
|
|
|
|
- "{{ osd_prepared.results }}"
|
2016-04-01 18:57:58 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- item.1.get("rc", 0) != 0
|
|
|
|
- ceph_osd_docker_prepare_env is defined
|
|
|
|
- osd_containerized_deployment_with_kv
|
2016-02-09 09:49:47 +08:00
|
|
|
|
2016-06-03 23:24:00 +08:00
|
|
|
# Use systemd to manage container on appropriate host
|
2016-02-10 01:35:41 +08:00
|
|
|
- name: generate systemd unit file
|
2016-03-22 23:58:20 +08:00
|
|
|
become: true
|
2016-02-10 03:49:22 +08:00
|
|
|
template:
|
2016-06-02 16:52:23 +08:00
|
|
|
src: "{{ role_path }}/templates/ceph-osd.service.j2"
|
2016-06-28 19:48:46 +08:00
|
|
|
dest: /etc/systemd/system/ceph-osd@.service
|
2016-02-10 01:35:41 +08:00
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0644"
|
|
|
|
failed_when: false
|
2016-06-03 23:24:00 +08:00
|
|
|
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
|
2016-02-10 01:35:41 +08:00
|
|
|
|
|
|
|
- name: enable systemd unit file for osd instance
|
2016-06-28 19:48:46 +08:00
|
|
|
shell: systemctl enable ceph-osd@{{ item | basename }}.service
|
2016-02-10 01:35:41 +08:00
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
2016-11-03 17:16:33 +08:00
|
|
|
with_items: "{{ ceph_osd_docker_devices }}"
|
2016-06-03 23:24:00 +08:00
|
|
|
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
|
2016-02-10 01:35:41 +08:00
|
|
|
|
|
|
|
- name: reload systemd unit files
|
|
|
|
shell: systemctl daemon-reload
|
2016-04-01 17:18:40 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2016-06-03 23:24:00 +08:00
|
|
|
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
|
2016-02-10 01:35:41 +08:00
|
|
|
|
|
|
|
- name: systemd start osd container
|
|
|
|
service:
|
|
|
|
name: ceph-osd@{{ item | basename }}
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
changed_when: false
|
2016-11-03 17:16:33 +08:00
|
|
|
with_items: "{{ ceph_osd_docker_devices }}"
|