]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-docker: osd fix container prep and start 673/head
authorSébastien Han <seb@redhat.com>
Fri, 1 Apr 2016 13:40:19 +0000 (15:40 +0200)
committerSébastien Han <seb@redhat.com>
Fri, 1 Apr 2016 13:40:19 +0000 (15:40 +0200)
We now check if the device has already been prepared, if we detect a
ceph partition we do not prepare the device.
Also fixed some issues while running on Atomic or CoreOS.

Signed-off-by: Sébastien Han <seb@redhat.com>
roles/ceph-osd/tasks/docker/start_docker_osd.yml

index c10313cf8ae7c4bda6c69b3742ed3096b8cf0bb0..929d6a0dd36d52848cd7cd8ac520627f0fa3ee87 100644 (file)
@@ -9,6 +9,13 @@
     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
+  changed_when: false
+  with_items: ceph_osd_docker_devices
+  register: osd_prepared
+
 - name: prepare ceph osd disk
   docker:
     image: "{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}"
     pid: host
     state: running
     privileged: yes
-    env: "OSD_DEVICE={{ item }},{{ ceph_osd_docker_prepare_env }}"
-    volumes: "/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph,/dev/:/dev/"
-  with_items: ceph_osd_docker_devices
+    env: "OSD_DEVICE={{ item.0 }},{{ ceph_osd_docker_prepare_env }}"
+    volumes: "/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph,{{ item.0 }}:{{ item.0 }}"
+  with_together:
+    - ceph_osd_docker_devices
+    - osd_prepared.results
   when:
+    item.1.get("rc", 0) != 0 and
     ceph_osd_docker_prepare_env is defined and
-    not osd_containerized_deployment_with_kv
+    not osd_containerized_deployment_with_kv and
+    not is_atomic and
+    not ansible_os_family == 'CoreOS'
 
 - name: prepare ceph osd disk with kv_store
   docker:
     pid: host
     state: running
     privileged: yes
-    volumes: "/dev/:/dev/"
-    env: "OSD_DEVICE={{ item }},KV_TYPE={{kv_type}},KV_IP={{kv_endpoint}},{{ ceph_osd_docker_prepare_env }}"
+    volumes: "{{ item.0 }}:{{ item.0 }}"
+    env: "OSD_DEVICE={{ item.0 }},KV_TYPE={{kv_type}},KV_IP={{kv_endpoint}},{{ ceph_osd_docker_prepare_env }}"
   ignore_errors: true
-  with_items: ceph_osd_docker_devices
+  with_together:
+    - ceph_osd_docker_devices
+    - osd_prepared.results
   when:
+    item.1.get("rc", 0) != 0 and
     ceph_osd_docker_prepare_env is defined and
+    osd_containerized_deployment_with_kv and
+    not is_atomic and
+    not ansible_os_family == 'CoreOS'
+
+me: prepare ceph osd disk for container operating systems
+  shell: |
+    docker run -d --net=host \
+    --pid=host \
+    --privileged=true \
+    -v /etc/ceph:/etc/ceph \
+    -v /var/lib/ceph/:/var/lib/ceph/ \
+    -v {{ item.0 }}:{{ item.0 }} \
+    -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
+  changed_when: false
+  with_together:
+    - ceph_osd_docker_devices
+    - osd_prepared.results
+  when:
+    item.1.get("rc", 0) != 0 and
+    is_atomic or
+    ansible_os_family == 'CoreOS' and
+    not osd_containerized_deployment_with_kv
+
+- name: prepare ceph osd disk for container operating systems with kv_store
+  shell: |
+    docker run -d --net=host \
+    --pid=host \
+    --privileged=true \
+    -e KV_TYPE={{ kv_type }} \
+    -e KV_IP={{ kv_endpoint }} \
+    -v {{ item.0 }}:{{ item.0 }} \
+    -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
+  changed_when: false
+  with_together:
+    - ceph_osd_docker_devices
+    - osd_prepared.results
+  when:
+    item.1.get("rc", 0) != 0 and
+    is_atomic or
+    ansible_os_family == 'CoreOS' and
     osd_containerized_deployment_with_kv
 
 # Use systemd to manage container on Atomic host
     group: "root"
     mode: "0644"
   failed_when: false
+  when:
+    is_atomic or
+    ansible_os_family == 'CoreOS'
 
 - name: link systemd unit file for osd instance
   file: