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 \
|
2017-02-08 05:00:53 +08:00
|
|
|
--name="{{ ansible_hostname }}-osd-prepare-{{ item.0 | regex_replace('/', '') }}" \
|
2016-05-12 23:25:12 +08:00
|
|
|
-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 }}" \
|
2017-02-08 05:00:53 +08:00
|
|
|
-e "OSD_JOURNAL_UUID=$(python -c "import uuid; print uuid.uuid5(uuid.NAMESPACE_DNS, '{{ ansible_machine_id }}{{ 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-02-09 22:16:39 +08:00
|
|
|
"{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_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 \
|
2017-02-08 05:00:53 +08:00
|
|
|
--name="{{ ansible_hostname }}-osd-prepare-{{ item.0 | regex_replace('/', '') }}" \
|
2016-06-28 19:48:46 +08:00
|
|
|
-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 }}" \
|
2017-02-08 05:00:53 +08:00
|
|
|
-e "OSD_JOURNAL_UUID=$(python -c "import uuid; print uuid.uuid5(uuid.NAMESPACE_DNS, '{{ ansible_machine_id }}{{ item.0 }}')")" \
|
2016-06-28 19:48:46 +08:00
|
|
|
-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-02-09 22:16:39 +08:00
|
|
|
"{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_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
|
|
|
|
2017-02-08 05:00:53 +08:00
|
|
|
- name: generate ceph osd docker run script
|
|
|
|
become: true
|
|
|
|
template:
|
|
|
|
src: "{{ role_path }}/templates/ceph-osd-run.sh.j2"
|
|
|
|
dest: /usr/share/ceph-osd-run.sh
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0744"
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
- 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
|
|
|
changed_when: false
|
2016-11-03 17:16:33 +08:00
|
|
|
with_items: "{{ ceph_osd_docker_devices }}"
|
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
|
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 }}"
|