ceph-ansible/roles/ceph-osd/tasks/docker/start_docker_osd.yml

134 lines
4.4 KiB
YAML
Raw Normal View History

---
# 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)
mount:
2016-02-20 03:46:33 +08:00
name: /mnt
src: /dev/vdb
fstype: ext3
state: unmounted
when: ceph_docker_on_openstack
- 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
# use shell rather than docker module
# to ensure osd disk prepare finishes before
# starting the next task
- name: prepare ceph osd disk
shell: |
docker run --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 \
-v /etc/localtime:/etc/localtime:ro \
-e "OSD_DEVICE={{ item.0 }}" \
-e "{{ ceph_osd_docker_prepare_env }}" \
"{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}" \
OSD_CEPH_DISK_PREPARE
with_together:
- ceph_osd_docker_devices
- osd_prepared.results
2016-04-01 18:57:58 +08:00
when:
- item.1.get("rc", 0) != 0
- ceph_osd_docker_prepare_env is defined
- not osd_containerized_deployment_with_kv
- name: prepare ceph osd disk with kv_store
shell: |
2016-07-06 15:58:49 +08:00
docker run --net=host \
--pid=host \
--privileged=true \
--name="{{ ansible_hostname }}-osd-prepare-{{ item.0 |
regex_replace('/', '') }}" \
-v /dev:/dev \
-v /etc/localtime:/etc/localtime:ro \
-e "OSD_DEVICE={{ item.0 }}" \
-e "{{ ceph_osd_docker_prepare_env }}" \
-e CEPH_DAEMON=osd_ceph_disk_prepare \
-e KV_TYPE={{kv_type}} \
-e KV_IP={{kv_endpoint}} \
-e KV_PORT={{kv_port}} \
"{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}" \
with_together:
- ceph_osd_docker_devices
- osd_prepared.results
2016-04-01 18:57:58 +08:00
when:
- item.1.get("rc", 0) != 0
- ceph_osd_docker_prepare_env is defined
- osd_containerized_deployment_with_kv
# Use systemd to manage container on appropriate host
- 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"
failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: enable systemd unit file for osd instance
shell: systemctl enable ceph-osd@{{ item | basename }}.service
failed_when: false
changed_when: false
with_items: ceph_osd_docker_devices
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: reload systemd unit files
shell: systemctl daemon-reload
changed_when: false
failed_when: false
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: systemd start osd container
service:
name: ceph-osd@{{ item | basename }}
state: started
enabled: yes
changed_when: false
with_items: ceph_osd_docker_devices
when: ansible_os_family == 'RedHat' or ansible_os_family == 'CoreOS'
- name: run the ceph osd docker image
2015-10-19 09:24:47 +08:00
docker:
2016-07-13 16:25:05 +08:00
image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}"
2015-10-19 09:24:47 +08:00
name: "{{ ansible_hostname }}-osd-{{ item | regex_replace('/', '') }}"
net: host
pid: host
state: started
2015-10-19 09:24:47 +08:00
privileged: yes
env: "OSD_DEVICE={{ item }},{{ ceph_osd_docker_extra_env }}"
volumes: "/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph,/etc/localtime:/etc/localtime:ro,/dev:/dev,/run:/run"
with_items: ceph_osd_docker_devices
2016-04-01 18:57:58 +08:00
when:
- ansible_os_family != 'RedHat'
- ansible_os_family != 'CoreOS'
- not osd_containerized_deployment_with_kv
2016-06-29 13:58:26 +08:00
- name: run the ceph osd docker image with kv
docker:
2016-07-13 16:25:05 +08:00
image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}:{{ ceph_osd_docker_image_tag }}"
2016-06-29 13:58:26 +08:00
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: "/etc/localtime:/etc/localtime:ro,/dev/:/dev/"
2016-06-29 13:58:26 +08:00
with_items: ceph_osd_docker_devices
when:
- ansible_os_family != 'RedHat'
- ansible_os_family != 'CoreOS'
- osd_containerized_deployment_with_kv