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
|
|
|
|
with_items: ceph_osd_docker_devices
|
|
|
|
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-05-12 23:25:12 +08:00
|
|
|
shell: |
|
|
|
|
docker run -ti --net=host \
|
|
|
|
--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 \
|
|
|
|
-e "OSD_DEVICE={{ item.0 }}" \
|
|
|
|
-e "{{ ceph_osd_docker_prepare_env }}" \
|
|
|
|
"{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}" \
|
|
|
|
OSD_CEPH_DISK_PREPARE
|
|
|
|
failed_when: false
|
2016-04-01 21:40:19 +08:00
|
|
|
with_together:
|
|
|
|
- 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
|
|
|
|
docker:
|
|
|
|
image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}"
|
|
|
|
name: "{{ ansible_hostname }}-osd-prepare-{{ item | regex_replace('/', '') }}"
|
|
|
|
net: host
|
|
|
|
pid: host
|
|
|
|
state: running
|
|
|
|
privileged: yes
|
2016-04-01 21:40:19 +08:00
|
|
|
volumes: "{{ item.0 }}:{{ item.0 }}"
|
|
|
|
env: "OSD_DEVICE={{ item.0 }},KV_TYPE={{kv_type}},KV_IP={{kv_endpoint}},{{ ceph_osd_docker_prepare_env }}"
|
2016-03-29 16:23:31 +08:00
|
|
|
ignore_errors: true
|
2016-04-01 21:40:19 +08:00
|
|
|
with_together:
|
|
|
|
- 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-02-10 01:35:41 +08:00
|
|
|
# Use systemd to manage container on Atomic host
|
|
|
|
- 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-04-15 05:57:27 +08:00
|
|
|
src: "{{ playbook_dir }}/roles/ceph-osd/templates/ceph-osd.service.j2"
|
2016-02-10 01:35:41 +08:00
|
|
|
dest: /var/lib/ceph/ceph-osd@.service
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0644"
|
|
|
|
failed_when: false
|
2016-05-09 22:08:33 +08:00
|
|
|
when: is_atomic or ansible_os_family == 'CoreOS'
|
2016-02-10 01:35:41 +08:00
|
|
|
|
|
|
|
- name: link systemd unit file for osd instance
|
|
|
|
file:
|
|
|
|
src: /var/lib/ceph/ceph-osd@.service
|
|
|
|
dest: /etc/systemd/system/multi-user.target.wants/ceph-osd@{{ item | basename }}.service
|
|
|
|
state: link
|
|
|
|
with_items: ceph_osd_docker_devices
|
2016-05-09 22:08:33 +08:00
|
|
|
when: is_atomic or ansible_os_family == 'CoreOS'
|
2016-02-10 01:35:41 +08:00
|
|
|
|
|
|
|
- name: enable systemd unit file for osd instance
|
|
|
|
shell: systemctl enable /etc/systemd/system/multi-user.target.wants/ceph-osd@{{ item | basename }}.service
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
|
|
|
with_items: ceph_osd_docker_devices
|
2016-05-09 22:08:33 +08:00
|
|
|
when: is_atomic 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-05-09 22:08:33 +08:00
|
|
|
when: is_atomic 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
|
|
|
|
with_items: ceph_osd_docker_devices
|
2016-05-09 22:08:33 +08:00
|
|
|
when: is_atomic or ansible_os_family == 'CoreOS'
|
2016-02-10 01:35:41 +08:00
|
|
|
|
2015-07-28 22:05:35 +08:00
|
|
|
- name: run the ceph osd docker image
|
2015-10-19 09:24:47 +08:00
|
|
|
docker:
|
|
|
|
image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}"
|
|
|
|
name: "{{ ansible_hostname }}-osd-{{ item | regex_replace('/', '') }}"
|
|
|
|
net: host
|
|
|
|
pid: host
|
2016-04-26 00:42:06 +08:00
|
|
|
state: started
|
2015-10-19 09:24:47 +08:00
|
|
|
privileged: yes
|
|
|
|
env: "OSD_DEVICE={{ item }},{{ ceph_osd_docker_extra_env }}"
|
2016-05-04 06:47:01 +08:00
|
|
|
volumes: "/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph,/dev:/dev,/run:/run"
|
2015-07-28 22:05:35 +08:00
|
|
|
with_items: ceph_osd_docker_devices
|
2016-04-01 18:57:58 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- not is_atomic
|
|
|
|
- ansible_os_family != 'CoreOS'
|
|
|
|
- not osd_containerized_deployment_with_kv
|
2016-03-30 18:22:15 +08:00
|
|
|
|
|
|
|
- name: run the ceph osd docker image with kv
|
|
|
|
docker:
|
|
|
|
image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}"
|
|
|
|
name: "{{ ansible_hostname }}-osd-{{ item | regex_replace('/', '') }}"
|
|
|
|
net: host
|
|
|
|
pid: host
|
|
|
|
state: running
|
|
|
|
privileged: yes
|
|
|
|
env: "KV_TYPE={{kv_type}},KV_IP={{kv_endpoint}},OSD_DEVICE={{ item }},{{ ceph_osd_docker_extra_env }}"
|
|
|
|
volumes: "/dev/:/dev/"
|
|
|
|
with_items: ceph_osd_docker_devices
|
2016-04-01 18:57:58 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- not is_atomic
|
|
|
|
- ansible_os_family != 'CoreOS'
|
|
|
|
- osd_containerized_deployment_with_kv
|