kolla-ansible/ansible/roles/ceph/tasks/bootstrap_osds.yml
Sam Yaple dd16395ae1 Switch find_disks to use a decent python lib
Now /dev/loop devices will work!

Change-Id: Icb8efe4f9bc3a21a72eb04bfd03452c26f13fd70
Closes-Bug: #1518438
2015-11-20 23:24:53 +00:00

106 lines
3.8 KiB
YAML

---
- name: Looking up disks to bootstrap for Ceph
command: docker exec -t kolla_ansible /usr/bin/ansible localhost
-m find_disks
-a "partition_name='KOLLA_CEPH_OSD_BOOTSTRAP'"
register: osd_lookup
changed_when: "{{ osd_lookup.stdout.find('localhost | SUCCESS => ') != -1 and (osd_lookup.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: osd_lookup.stdout.split()[2] != 'SUCCESS'
- name: Reading data from variable
set_fact:
osds_bootstrap: "{{ (osd_lookup.stdout.split('localhost | SUCCESS => ')[1]|from_json).disks|from_json }}"
- name: Looking up disks to bootstrap for Ceph
command: docker exec -t kolla_ansible /usr/bin/ansible localhost
-m find_disks
-a "partition_name='KOLLA_CEPH_OSD_CACHE_BOOTSTRAP'"
register: osd_cache_lookup
changed_when: "{{ osd_cache_lookup.stdout.find('localhost | SUCCESS => ') != -1 and (osd_cache_lookup.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
failed_when: osd_cache_lookup.stdout.split()[2] != 'SUCCESS'
- name: Reading data from variable
set_fact:
osds_cache_bootstrap: "{{ (osd_cache_lookup.stdout.split('localhost | SUCCESS => ')[1]|from_json).disks|from_json }}"
- name: Bootstrapping Ceph OSDs
docker:
tty: True
net: host
pull: "{{ docker_pull_policy }}"
restart_policy: "no"
state: reloaded
registry: "{{ docker_registry }}"
username: "{{ docker_registry_username }}"
password: "{{ docker_registry_password }}"
insecure_registry: "{{ docker_insecure_registry }}"
privileged: True
name: "bootstrap_osd_{{ item.0 }}"
image: "{{ ceph_osd_image_full }}"
volumes:
- "{{ node_config_directory }}/ceph-osd/:{{ container_config_directory }}/:ro"
- "/dev/:/dev/"
env:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
OSD_DEV: "{{ item.1.device }}"
OSD_INITIAL_WEIGHT: "{{ osd_initial_weight }}"
with_indexed_items: osds_bootstrap|default([])
# https://github.com/ansible/ansible-modules-core/pull/1031
- name: Waiting for bootstrap containers to exit
command: docker wait "bootstrap_osd_{{ item.0 }}"
register: bootstrap_result
run_once: True
failed_when: bootstrap_result.stdout != "0"
with_indexed_items: osds_bootstrap|default([])
- name: Cleaning up bootstrap containers
docker:
tty: True
name: "bootstrap_osd_{{ item.0 }}"
image: "{{ ceph_osd_image_full }}"
state: absent
with_indexed_items: osds_bootstrap|default([])
- name: Bootstrapping Ceph Cache OSDs
docker:
tty: True
net: host
pull: "{{ docker_pull_policy }}"
restart_policy: "no"
state: reloaded
registry: "{{ docker_registry }}"
username: "{{ docker_registry_username }}"
password: "{{ docker_registry_password }}"
insecure_registry: "{{ docker_insecure_registry }}"
privileged: True
name: "bootstrap_osd_cache_{{ item.0 }}"
image: "{{ ceph_osd_image_full }}"
volumes:
- "{{ node_config_directory }}/ceph-osd/:{{ container_config_directory }}/:ro"
- "/dev/:/dev/"
env:
KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
CEPH_CACHE:
OSD_DEV: "{{ item.1.device }}"
OSD_INITIAL_WEIGHT: "{{ osd_initial_weight }}"
with_indexed_items: osds_cache_bootstrap|default([])
# https://github.com/ansible/ansible-modules-core/pull/1031
- name: Waiting for bootstrap containers to exit
command: docker wait "bootstrap_osd_cache_{{ item.0 }}"
register: bootstrap_result
run_once: True
failed_when: bootstrap_result.stdout != "0"
with_indexed_items: osds_cache_bootstrap|default([])
- name: Cleaning up bootstrap containers
docker:
tty: True
name: "bootstrap_osd_cache_{{ item.0 }}"
image: "{{ ceph_osd_image_full }}"
state: absent
with_indexed_items: osds_cache_bootstrap|default([])