From fea0cc87ec188ab4f5a29c3a7c7d1e6bf0d937fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 28 Jul 2015 17:15:19 +0200 Subject: [PATCH] Re-arrange docker invocation and fix bootstrap mds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Han --- group_vars/mdss.sample | 1 + roles/ceph-mds/defaults/main.yml | 1 + roles/ceph-mds/tasks/docker/fetch_configs.yml | 29 +++++++++++++++++++ roles/ceph-mds/tasks/docker/main.yml | 4 +++ roles/ceph-mds/tasks/docker/pre_requisite.yml | 11 +++++++ .../tasks/docker/start_docker_mds.yml | 9 ++++++ roles/ceph-mds/tasks/main.yml | 2 +- 7 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 roles/ceph-mds/tasks/docker/fetch_configs.yml create mode 100644 roles/ceph-mds/tasks/docker/main.yml create mode 100644 roles/ceph-mds/tasks/docker/pre_requisite.yml create mode 100644 roles/ceph-mds/tasks/docker/start_docker_mds.yml diff --git a/group_vars/mdss.sample b/group_vars/mdss.sample index 22fa5722e..031ece6ba 100644 --- a/group_vars/mdss.sample +++ b/group_vars/mdss.sample @@ -11,3 +11,4 @@ dummy: #ceph_containerized_deployment: false #ceph_mds_docker_username: ceph #ceph_mds_docker_imagename: daemon +#ceph_mds_docker_extra_envs: "MDS_NAME={{ ansible_hostname }}" # comma separated variables diff --git a/roles/ceph-mds/defaults/main.yml b/roles/ceph-mds/defaults/main.yml index fc5abef35..c4de31f68 100644 --- a/roles/ceph-mds/defaults/main.yml +++ b/roles/ceph-mds/defaults/main.yml @@ -11,3 +11,4 @@ cephx: true ceph_containerized_deployment: false ceph_mds_docker_username: ceph ceph_mds_docker_imagename: daemon +ceph_mds_docker_extra_envs: "MDS_NAME={{ ansible_hostname }}" # comma separated variables diff --git a/roles/ceph-mds/tasks/docker/fetch_configs.yml b/roles/ceph-mds/tasks/docker/fetch_configs.yml new file mode 100644 index 000000000..06c5693dc --- /dev/null +++ b/roles/ceph-mds/tasks/docker/fetch_configs.yml @@ -0,0 +1,29 @@ +--- +# NOTE (leseb): the mds container needs the admin key +# so it can create the mds pools for cephfs +- name: set config and keys paths + set_fact: + ceph_config_keys: + - /etc/ceph/ceph.conf + - /etc/ceph/ceph.client.admin.keyring + - /var/lib/ceph/bootstrap-mds/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-mds/tasks/docker/main.yml b/roles/ceph-mds/tasks/docker/main.yml new file mode 100644 index 000000000..0b859c242 --- /dev/null +++ b/roles/ceph-mds/tasks/docker/main.yml @@ -0,0 +1,4 @@ +--- +- include: pre_requisite.yml +- include: fetch_configs.yml +- include: start_docker_mds.yml diff --git a/roles/ceph-mds/tasks/docker/pre_requisite.yml b/roles/ceph-mds/tasks/docker/pre_requisite.yml new file mode 100644 index 000000000..5ba88d842 --- /dev/null +++ b/roles/ceph-mds/tasks/docker/pre_requisite.yml @@ -0,0 +1,11 @@ +--- +- name: create mds bootstrap directory + file: > + path=/var/lib/ceph/bootstrap-mds + 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-mds/tasks/docker/start_docker_mds.yml b/roles/ceph-mds/tasks/docker/start_docker_mds.yml new file mode 100644 index 000000000..dc9e16727 --- /dev/null +++ b/roles/ceph-mds/tasks/docker/start_docker_mds.yml @@ -0,0 +1,9 @@ +--- +- name: run the ceph medata docker image + docker: > + image="{{ ceph_mds_docker_username }}/{{ ceph_mds_docker_imagename }}" + name=ceph-{{ ansible_hostname }}-mds + net=host + state=running + env="CEPHFS_CREATE=1,{{ ceph_osd_docker_extra_env }}" + volumes="/var/lib/ceph:/var/lib/ceph,/etc/ceph:/etc/ceph" diff --git a/roles/ceph-mds/tasks/main.yml b/roles/ceph-mds/tasks/main.yml index fcdbce94e..40a43dd09 100644 --- a/roles/ceph-mds/tasks/main.yml +++ b/roles/ceph-mds/tasks/main.yml @@ -2,5 +2,5 @@ - include: pre_requisite.yml when: not ceph_containerized_deployment -- include: docker.yml +- include: ./docker/main.yml when: ceph_containerized_deployment