2016-05-11 00:29:27 +08:00
|
|
|
|
---
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: run a dummy container (sleep 300) from where we can create pool(s)/key(s)
|
|
|
|
|
command: >
|
|
|
|
|
docker run \
|
|
|
|
|
-d \
|
|
|
|
|
-v {{ ceph_conf_key_directory }}:{{ ceph_conf_key_directory }} \
|
|
|
|
|
--name ceph-create-keys \
|
|
|
|
|
--entrypoint=sleep \
|
|
|
|
|
{{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} \
|
|
|
|
|
300
|
|
|
|
|
changed_when: false
|
|
|
|
|
run_once: true
|
2017-09-14 04:13:53 +08:00
|
|
|
|
when: containerized_deployment
|
|
|
|
|
|
|
|
|
|
- name: set docker_exec_client_cmd for containers
|
|
|
|
|
set_fact:
|
2018-04-04 22:22:36 +08:00
|
|
|
|
docker_exec_client_cmd: "docker exec ceph-create-keys"
|
|
|
|
|
run_once: true
|
2017-09-14 04:13:53 +08:00
|
|
|
|
when: containerized_deployment
|
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: create cephx key(s)
|
|
|
|
|
ceph_key:
|
|
|
|
|
state: present
|
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
|
caps: "{{ item.caps }}"
|
|
|
|
|
secret: "{{ item.key | default('') }}"
|
|
|
|
|
containerized: "{{ docker_exec_client_cmd | default('') }}"
|
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
|
dest: "{{ ceph_conf_key_directory }}"
|
2016-11-03 17:16:33 +08:00
|
|
|
|
with_items: "{{ keys }}"
|
2018-03-30 19:48:17 +08:00
|
|
|
|
run_once: true
|
2017-07-13 23:39:35 +08:00
|
|
|
|
when:
|
|
|
|
|
- cephx
|
|
|
|
|
- keys | length > 0
|
2018-03-30 19:48:17 +08:00
|
|
|
|
- inventory_hostname in groups.get(client_group_name) | first
|
2017-07-13 23:39:35 +08:00
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: slurp client cephx key(s)
|
2018-03-30 19:48:17 +08:00
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ ceph_conf_key_directory }}/{{ cluster }}.{{ item.name }}.keyring"
|
|
|
|
|
with_items:
|
|
|
|
|
- "{{ keys }}"
|
|
|
|
|
register: slurp_client_keys
|
|
|
|
|
run_once: true
|
|
|
|
|
when:
|
|
|
|
|
- cephx
|
|
|
|
|
- keys | length > 0
|
|
|
|
|
- inventory_hostname in groups.get(client_group_name) | first
|
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: create ceph pool(s)
|
2018-03-07 21:50:27 +08:00
|
|
|
|
command: >
|
2018-04-04 22:22:36 +08:00
|
|
|
|
{{ docker_exec_client_cmd | default('') }} ceph --cluster {{ cluster }}
|
2018-03-07 21:50:27 +08:00
|
|
|
|
osd pool create {{ item.name }}
|
|
|
|
|
{{ item.get('pg_num', hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num']) }}
|
|
|
|
|
{{ item.pgp_num | default(item.pg_num) }}
|
|
|
|
|
{{ item.rule_name | default("replicated_rule") }}
|
|
|
|
|
{{ item.type | default("replicated") }}
|
|
|
|
|
{%- if item.type | default("replicated") == 'erasure' and item.erasure_profile != '' %}
|
|
|
|
|
{{ item.erasure_profile }}
|
|
|
|
|
{%- endif %}
|
2018-03-26 04:36:27 +08:00
|
|
|
|
{{ item.expected_num_objects | default('') }}
|
2017-09-14 04:13:53 +08:00
|
|
|
|
with_items: "{{ pools }}"
|
|
|
|
|
changed_when: false
|
2018-03-30 19:48:17 +08:00
|
|
|
|
run_once: true
|
2017-09-14 04:13:53 +08:00
|
|
|
|
when:
|
|
|
|
|
- pools | length > 0
|
|
|
|
|
- copy_admin_key
|
2018-03-30 19:48:17 +08:00
|
|
|
|
- inventory_hostname in groups.get(client_group_name) | first
|
2017-09-14 04:13:53 +08:00
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: kill a dummy container that created pool(s)/key(s)
|
|
|
|
|
command: docker rm -f ceph-create-keys
|
2017-07-13 23:39:35 +08:00
|
|
|
|
changed_when: false
|
2018-03-30 19:48:17 +08:00
|
|
|
|
run_once: true
|
2018-04-04 22:22:36 +08:00
|
|
|
|
when: containerized_deployment
|
2017-09-14 04:13:53 +08:00
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: get client cephx keys
|
2018-03-30 19:48:17 +08:00
|
|
|
|
copy:
|
|
|
|
|
dest: "{{ item.source }}"
|
|
|
|
|
content: "{{ item.content | b64decode }}"
|
|
|
|
|
with_items:
|
|
|
|
|
- "{{ slurp_client_keys.results }}"
|
|
|
|
|
when:
|
|
|
|
|
- not item.get('skipped', False)
|
|
|
|
|
- not inventory_hostname == groups.get(client_group_name, []) | first
|
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: chmod cephx key(s)
|
2017-10-26 07:46:02 +08:00
|
|
|
|
file:
|
2018-04-04 22:22:36 +08:00
|
|
|
|
path: "{{ ceph_conf_key_directory }}/{{ cluster }}.{{ item.name }}.keyring"
|
2017-10-26 07:46:02 +08:00
|
|
|
|
mode: "{{ item.mode|default(omit) }}" # if mode not in list, uses mode from ps umask
|
|
|
|
|
with_items: "{{ keys }}"
|
|
|
|
|
when:
|
|
|
|
|
- cephx
|
|
|
|
|
- keys | length > 0
|
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
|
- name: setfacl for cephx key(s)
|
2017-07-20 06:20:18 +08:00
|
|
|
|
acl:
|
2018-04-04 22:22:36 +08:00
|
|
|
|
path: "{{ ceph_conf_key_directory }}/{{ cluster }}.{{ item.0.name }}.keyring"
|
2017-07-20 06:20:18 +08:00
|
|
|
|
entry: "{{ item.1 }}"
|
|
|
|
|
state: present
|
|
|
|
|
with_subelements:
|
|
|
|
|
- "{{ keys }}"
|
|
|
|
|
- acls
|
|
|
|
|
- skip_missing: true
|
|
|
|
|
when:
|
|
|
|
|
- cephx
|
|
|
|
|
- keys | length > 0
|