From 0c21fb3f668dadf98b199ffafd9ffdf7ef404cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 23 Jun 2017 16:05:35 +0200 Subject: [PATCH] docker: ability to change ceph config directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Han --- group_vars/all.yml.sample | 4 +++- roles/ceph-docker-common/defaults/main.yml | 4 +++- roles/ceph-docker-common/tasks/checks.yml | 8 ++++---- roles/ceph-docker-common/tasks/create_configs.yml | 2 +- roles/ceph-docker-common/tasks/dirs_permissions.yml | 2 +- roles/ceph-docker-common/tasks/fetch_configs.yml | 10 +++++----- roles/ceph-docker-common/tasks/selinux.yml | 5 +++-- roles/ceph-mon/tasks/docker/main.yml | 8 ++++---- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/group_vars/all.yml.sample b/group_vars/all.yml.sample index cc6fd4a12..78be891fb 100644 --- a/group_vars/all.yml.sample +++ b/group_vars/all.yml.sample @@ -418,7 +418,9 @@ dummy: # These values have to be set according to the base OS used by the container image, NOT the host. #bootstrap_dirs_owner: "64045" #bootstrap_dirs_group: "64045" -# + +#ceph_conf_key_directory: /etc/ceph + ############ # KV store # ############ diff --git a/roles/ceph-docker-common/defaults/main.yml b/roles/ceph-docker-common/defaults/main.yml index f9f5a8a05..e2ea55803 100644 --- a/roles/ceph-docker-common/defaults/main.yml +++ b/roles/ceph-docker-common/defaults/main.yml @@ -13,7 +13,9 @@ mon_use_fqdn: false # if set to true, the MON name used will be the fqdn # These values have to be set according to the base OS used by the container image, NOT the host. bootstrap_dirs_owner: "64045" bootstrap_dirs_group: "64045" -# + +ceph_conf_key_directory: /etc/ceph + ############ # KV store # ############ diff --git a/roles/ceph-docker-common/tasks/checks.yml b/roles/ceph-docker-common/tasks/checks.yml index 968fc038c..7ed5ac462 100644 --- a/roles/ceph-docker-common/tasks/checks.yml +++ b/roles/ceph-docker-common/tasks/checks.yml @@ -2,10 +2,10 @@ - name: set config and keys paths set_fact: ceph_config_keys: - - /etc/ceph/{{ cluster }}.client.admin.keyring - - /etc/ceph/{{ cluster }}.conf - - /etc/ceph/monmap-{{ cluster }} - - /etc/ceph/{{ cluster }}.mon.keyring + - "{{ ceph_conf_key_directory }}/{{ cluster }}.client.admin.keyring" + - "{{ ceph_conf_key_directory }}/{{ cluster }}.conf" + - "{{ ceph_conf_key_directory }}/monmap-{{ cluster }}" + - "{{ ceph_conf_key_directory }}/{{ cluster }}.mon.keyring" - /var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring - /var/lib/ceph/bootstrap-rgw/{{ cluster }}.keyring - /var/lib/ceph/bootstrap-mds/{{ cluster }}.keyring diff --git a/roles/ceph-docker-common/tasks/create_configs.yml b/roles/ceph-docker-common/tasks/create_configs.yml index 2ea58c721..fbee9dcad 100644 --- a/roles/ceph-docker-common/tasks/create_configs.yml +++ b/roles/ceph-docker-common/tasks/create_configs.yml @@ -26,7 +26,7 @@ action: config_template args: src: "{{ playbook_dir }}/roles/ceph-common/templates/ceph.conf.j2" - dest: "/etc/ceph/{{ cluster }}.conf" + dest: "{{ ceph_conf_key_directory }}/{{ cluster }}.conf" owner: "root" group: "root" mode: "0644" diff --git a/roles/ceph-docker-common/tasks/dirs_permissions.yml b/roles/ceph-docker-common/tasks/dirs_permissions.yml index 65997fd08..4c174d751 100644 --- a/roles/ceph-docker-common/tasks/dirs_permissions.yml +++ b/roles/ceph-docker-common/tasks/dirs_permissions.yml @@ -7,7 +7,7 @@ group: "{{ bootstrap_dirs_group }}" mode: "0755" with_items: - - /etc/ceph/ + - "{{ ceph_conf_key_directory }}" - /var/lib/ceph/bootstrap-osd - /var/lib/ceph/bootstrap-mds - /var/lib/ceph/bootstrap-rgw diff --git a/roles/ceph-docker-common/tasks/fetch_configs.yml b/roles/ceph-docker-common/tasks/fetch_configs.yml index a96f34c88..ac432dd6c 100644 --- a/roles/ceph-docker-common/tasks/fetch_configs.yml +++ b/roles/ceph-docker-common/tasks/fetch_configs.yml @@ -2,17 +2,17 @@ - name: set config and keys paths set_fact: ceph_config_keys: - - /etc/ceph/{{ cluster }}.conf - - /etc/ceph/{{ cluster }}.client.admin.keyring - - /etc/ceph/monmap-{{ cluster }} - - /etc/ceph/{{ cluster }}.mon.keyring + - "{{ ceph_conf_key_directory }}/{{ cluster }}.conf" + - "{{ ceph_conf_key_directory }}/{{ cluster }}.client.admin.keyring" + - "{{ ceph_conf_key_directory }}/monmap-{{ cluster }}" + - "{{ ceph_conf_key_directory }}/{{ cluster }}.mon.keyring" - /var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring - /var/lib/ceph/bootstrap-rgw/{{ cluster }}.keyring - /var/lib/ceph/bootstrap-mds/{{ cluster }}.keyring - name: add mgr keys to config and keys paths set_fact: - tmp_ceph_mgr_keys: /etc/ceph/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring + tmp_ceph_mgr_keys: "{{ ceph_conf_key_directory }}/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring" with_items: "{{ groups.get(mgr_group_name, []) }}" register: tmp_ceph_mgr_keys_result when: "{{ groups.get(mgr_group_name, []) | length > 0 }}" diff --git a/roles/ceph-docker-common/tasks/selinux.yml b/roles/ceph-docker-common/tasks/selinux.yml index 6d4ee022f..648d9e7ad 100644 --- a/roles/ceph-docker-common/tasks/selinux.yml +++ b/roles/ceph-docker-common/tasks/selinux.yml @@ -6,9 +6,10 @@ always_run: true - name: set selinux permissions - shell: chcon -Rt svirt_sandbox_file_t {{ item }} + shell: | + chcon -Rt svirt_sandbox_file_t {{ item }} with_items: - - /etc/ceph + - "{{ ceph_conf_key_directory }}" - /var/lib/ceph changed_when: false when: sestatus.stdout != 'Disabled' diff --git a/roles/ceph-mon/tasks/docker/main.yml b/roles/ceph-mon/tasks/docker/main.yml index fe49404c3..1f9130b8f 100644 --- a/roles/ceph-mon/tasks/docker/main.yml +++ b/roles/ceph-mon/tasks/docker/main.yml @@ -27,7 +27,7 @@ - name: create ceph rest api keyring when mon is containerized command: docker exec ceph-mon-{{ ansible_hostname }} ceph --cluster {{ cluster }} auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/{{ cluster }}.client.restapi.keyring args: - creates: /etc/ceph/{{ cluster }}.client.restapi.keyring + creates: "{{ ceph_conf_key_directory }}/{{ cluster }}.client.restapi.keyring" changed_when: false when: - cephx @@ -48,7 +48,7 @@ - name: create ceph mgr keyring(s) when mon is containerized command: docker exec ceph-mon-{{ ansible_hostname }} ceph --cluster {{ cluster }} auth get-or-create mgr.{{ hostvars[item]['ansible_hostname'] }} mon 'allow profile mgr' osd 'allow *' mds 'allow *' -o /etc/ceph/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring args: - creates: /etc/ceph/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring + creates: "{{ ceph_conf_key_directory }}/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring" changed_when: false when: - cephx @@ -59,7 +59,7 @@ - name: stat for ceph mgr key(s) stat: - path: /etc/ceph/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring + path: "{{ ceph_conf_key_directory }}/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring" with_items: "{{ groups.get(mgr_group_name, []) }}" changed_when: false become: false @@ -71,7 +71,7 @@ - name: push ceph mgr key(s) fetch: - src: "/etc/ceph/{{ cluster }}.mgr.{{ hostvars[item.item]['ansible_hostname'] }}.keyring" + src: "{{ ceph_conf_key_directory }}/{{ cluster }}.mgr.{{ hostvars[item.item]['ansible_hostname'] }}.keyring" dest: "{{ fetch_directory }}/docker_mon_files/{{ item.stat.path }}" flat: yes with_items: