2016-05-11 00:29:27 +08:00
|
|
|
---
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact delegated_node
|
|
|
|
ansible.builtin.set_fact:
|
2018-05-01 02:53:42 +08:00
|
|
|
delegated_node: "{{ groups[mon_group_name][0] if groups.get(mon_group_name, []) | length > 0 else inventory_hostname }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact admin_key_presence
|
|
|
|
ansible.builtin.set_fact:
|
2020-03-27 23:21:09 +08:00
|
|
|
admin_key_presence: "{{ True if groups.get(mon_group_name, []) | length > 0 else copy_admin_key }}"
|
2018-05-01 02:53:42 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create cephx key(s)
|
2018-04-04 22:22:36 +08:00
|
|
|
ceph_key:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
caps: "{{ item.caps }}"
|
|
|
|
secret: "{{ item.key | default('') }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
dest: "{{ ceph_conf_key_directory }}"
|
2020-03-27 23:21:09 +08:00
|
|
|
import_key: "{{ admin_key_presence }}"
|
2020-11-02 22:56:28 +08:00
|
|
|
mode: "{{ item.mode | default(ceph_keyring_permissions) }}"
|
2020-09-26 00:15:02 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
2018-11-18 02:58:54 +08:00
|
|
|
environment:
|
2020-09-26 00:15:02 +08:00
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
2018-11-18 23:10:11 +08:00
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2019-05-20 21:58:10 +08:00
|
|
|
with_items:
|
|
|
|
- "{{ keys }}"
|
2018-06-06 19:59:26 +08:00
|
|
|
delegate_to: "{{ delegated_node }}"
|
2017-07-13 23:39:35 +08:00
|
|
|
when:
|
2019-05-22 16:02:42 +08:00
|
|
|
- cephx | bool
|
2017-07-13 23:39:35 +08:00
|
|
|
- keys | length > 0
|
2019-03-05 15:44:25 +08:00
|
|
|
- inventory_hostname == groups.get('_filtered_clients') | first
|
2021-08-09 20:57:33 +08:00
|
|
|
no_log: "{{ no_log_on_ceph_key_tasks }}"
|
2017-07-13 23:39:35 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Slurp client cephx key(s)
|
|
|
|
ansible.builtin.slurp:
|
2018-03-30 19:48:17 +08:00
|
|
|
src: "{{ ceph_conf_key_directory }}/{{ cluster }}.{{ item.name }}.keyring"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ keys }}"
|
2018-03-30 19:48:17 +08:00
|
|
|
register: slurp_client_keys
|
2018-06-06 19:59:26 +08:00
|
|
|
delegate_to: "{{ delegated_node }}"
|
2018-03-30 19:48:17 +08:00
|
|
|
when:
|
2019-05-22 16:02:42 +08:00
|
|
|
- cephx | bool
|
2018-03-30 19:48:17 +08:00
|
|
|
- keys | length > 0
|
2019-03-05 15:44:25 +08:00
|
|
|
- inventory_hostname == groups.get('_filtered_clients') | first
|
2021-08-09 20:57:33 +08:00
|
|
|
no_log: "{{ no_log_on_ceph_key_tasks }}"
|
2018-03-30 19:48:17 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Pool related tasks
|
2018-04-27 20:48:33 +08:00
|
|
|
when:
|
2020-03-27 23:21:09 +08:00
|
|
|
- admin_key_presence | bool
|
2018-08-30 15:53:36 +08:00
|
|
|
- inventory_hostname == groups.get('_filtered_clients', []) | first
|
2018-10-01 23:11:13 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Import ceph-facts role
|
|
|
|
ansible.builtin.import_role:
|
2020-03-27 23:21:09 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: get_def_crush_rule_name.yml
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create ceph pool(s)
|
2020-04-29 00:08:59 +08:00
|
|
|
ceph_pool:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
2020-09-29 05:27:47 +08:00
|
|
|
pg_num: "{{ item.pg_num | default(omit) }}"
|
|
|
|
pgp_num: "{{ item.pgp_num | default(omit) }}"
|
2020-09-11 16:29:28 +08:00
|
|
|
size: "{{ item.size | default(omit) }}"
|
|
|
|
min_size: "{{ item.min_size | default(omit) }}"
|
2020-04-29 00:08:59 +08:00
|
|
|
pool_type: "{{ item.type | default('replicated') }}"
|
2020-09-11 16:29:28 +08:00
|
|
|
rule_name: "{{ item.rule_name | default(omit) }}"
|
2020-04-29 00:08:59 +08:00
|
|
|
erasure_profile: "{{ item.erasure_profile | default(omit) }}"
|
|
|
|
pg_autoscale_mode: "{{ item.pg_autoscale_mode | default(omit) }}"
|
|
|
|
target_size_ratio: "{{ item.target_size_ratio | default(omit) }}"
|
|
|
|
application: "{{ item.application | default(omit) }}"
|
|
|
|
environment:
|
2020-09-26 00:15:02 +08:00
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
2020-04-29 00:08:59 +08:00
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
with_items: "{{ pools }}"
|
2019-03-01 00:46:29 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ delegated_node }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Get client cephx keys
|
|
|
|
ansible.builtin.copy:
|
2019-03-01 23:41:55 +08:00
|
|
|
dest: "{{ item.source }}"
|
2018-03-30 19:48:17 +08:00
|
|
|
content: "{{ item.content | b64decode }}"
|
2018-06-07 21:49:03 +08:00
|
|
|
mode: "{{ item.item.get('mode', '0600') }}"
|
2018-04-23 16:02:16 +08:00
|
|
|
owner: "{{ ceph_uid }}"
|
|
|
|
group: "{{ ceph_uid }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
with_items: "{{ hostvars[groups['_filtered_clients'][0]]['slurp_client_keys']['results'] }}"
|
|
|
|
when: not item.get('skipped', False)
|
2021-08-09 20:57:33 +08:00
|
|
|
no_log: "{{ no_log_on_ceph_key_tasks }}"
|