diff --git a/group_vars/osds.sample b/group_vars/osds.sample index 640c9e86a..15a116dba 100644 --- a/group_vars/osds.sample +++ b/group_vars/osds.sample @@ -114,5 +114,6 @@ osd_crush_location: "'root={{ ceph_crush_root }} rack={{ ceph_crush_rack }} host #ceph_containerized_deployment: false #ceph_osd_docker_username: ceph #ceph_osd_docker_imagename: daemon -#ceph_osd_docker_devices: -# - /dev/sdb +#ceph_osd_docker_extra_env: "CEPH_DAEMON=OSD_CEPH_DISK" # comma separated variables +#ceph_osd_docker_device: +# - /dev/sdb diff --git a/roles/ceph-osd/defaults/main.yml b/roles/ceph-osd/defaults/main.yml index c32b25614..1703fb6b3 100644 --- a/roles/ceph-osd/defaults/main.yml +++ b/roles/ceph-osd/defaults/main.yml @@ -109,4 +109,6 @@ osd_directory: false ceph_containerized_deployment: false ceph_osd_docker_username: ceph ceph_osd_docker_imagename: daemon -#ceph_osd_docker_device: /dev/sdb +ceph_osd_docker_extra_env: "CEPH_DAEMON=OSD_CEPH_DISK" # comma separated variables +#ceph_osd_docker_device: +# - /dev/sdb diff --git a/roles/ceph-osd/tasks/docker/fetch_configs.yml b/roles/ceph-osd/tasks/docker/fetch_configs.yml new file mode 100644 index 000000000..c4f00d47d --- /dev/null +++ b/roles/ceph-osd/tasks/docker/fetch_configs.yml @@ -0,0 +1,26 @@ +--- +- name: set config and keys paths + set_fact: + ceph_config_keys: + - /etc/ceph/ceph.conf + - /var/lib/ceph/bootstrap-osd/ceph.keyring + +- name: stat for ceph config and keys + local_action: stat path={{ item }} + with_items: ceph_config_keys + changed_when: false + sudo: false + ignore_errors: true + register: statconfig + +- name: try to fetch ceph config and keys + copy: > + src=fetch/docker_mon_files/{{ item.0 }} + dest={{ item.0 }} + owner=root + group=root + mode=644 + with_together: + - ceph_config_keys + - statconfig.results + when: item.1.stat.exists == true diff --git a/roles/ceph-osd/tasks/docker/main.yml b/roles/ceph-osd/tasks/docker/main.yml new file mode 100644 index 000000000..149043f7a --- /dev/null +++ b/roles/ceph-osd/tasks/docker/main.yml @@ -0,0 +1,4 @@ +--- +- include: pre_requisite.yml +- include: fetch_configs.yml +- include: start_docker_osd.yml diff --git a/roles/ceph-osd/tasks/docker/pre_requisite.yml b/roles/ceph-osd/tasks/docker/pre_requisite.yml new file mode 100644 index 000000000..77ed25fd2 --- /dev/null +++ b/roles/ceph-osd/tasks/docker/pre_requisite.yml @@ -0,0 +1,11 @@ +--- +- name: create osd bootstrap directory + file: > + path=/var/lib/ceph/bootstrap-osd + state=directory + +# NOTE (leseb): for version 1.1.0 because https://github.com/ansible/ansible-modules-core/issues/1227 +- name: install docker-py + pip: > + name=docker-py + version=1.1.0 diff --git a/roles/ceph-osd/tasks/docker/start_docker_osd.yml b/roles/ceph-osd/tasks/docker/start_docker_osd.yml new file mode 100644 index 000000000..82bbb7218 --- /dev/null +++ b/roles/ceph-osd/tasks/docker/start_docker_osd.yml @@ -0,0 +1,11 @@ +--- +- name: run the ceph osd docker image + docker: > + image="{{ ceph_osd_docker_username }}/{{ ceph_osd_docker_imagename }}" + name={{ ansible_hostname }}-osd-{{ item | regex_replace('/', '') }} + net=host + state=running + privileged=yes + env="OSD_DEVICE={{ item }},{{ ceph_osd_docker_extra_env }}" + volumes="/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph,/dev/:/dev/" + with_items: ceph_osd_docker_devices diff --git a/roles/ceph-osd/tasks/main.yml b/roles/ceph-osd/tasks/main.yml index c092f933e..f6070888f 100644 --- a/roles/ceph-osd/tasks/main.yml +++ b/roles/ceph-osd/tasks/main.yml @@ -12,5 +12,5 @@ - include: ./scenarios/osd_directory.yml when: osd_directory and not ceph_containerized_deployment -- include: ./scenarios/docker.yml +- include: ./docker/main.yml when: ceph_containerized_deployment