2016-05-11 00:29:27 +08:00
|
|
|
|
---
|
|
|
|
|
- name: create pools
|
2017-07-13 23:39:35 +08:00
|
|
|
|
command: "ceph --cluster {{ cluster }} osd pool create {{ item.name }} {{ item.pgs }}"
|
2016-11-03 17:16:33 +08:00
|
|
|
|
with_items: "{{ pools }}"
|
2016-05-11 00:29:27 +08:00
|
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
2017-07-13 23:39:35 +08:00
|
|
|
|
when: pools | length > 0
|
2016-05-11 00:29:27 +08:00
|
|
|
|
|
2017-07-13 23:39:35 +08:00
|
|
|
|
- name: create key(s)
|
|
|
|
|
shell: "ceph-authtool -C /etc/ceph/{{ cluster }}.{{ item.name }}.keyring --name {{ item.name }} --add-key {{ item.key }} --cap mon \"{{ item.mon_cap|default('') }}\" --cap osd \"{{ item.osd_cap|default('') }}\" --cap mds \"{{ item.mds_cap|default('') }}\""
|
2016-05-11 00:29:27 +08:00
|
|
|
|
args:
|
|
|
|
|
creates: /etc/ceph/{{ cluster }}.{{ item.name }}.keyring
|
2016-11-03 17:16:33 +08:00
|
|
|
|
with_items: "{{ keys }}"
|
2016-05-11 00:29:27 +08:00
|
|
|
|
changed_when: false
|
2017-07-13 23:39:35 +08:00
|
|
|
|
when:
|
|
|
|
|
- cephx
|
|
|
|
|
- keys | length > 0
|
|
|
|
|
|
|
|
|
|
- name: check if key(s) already exist(s)
|
|
|
|
|
command: "ceph --cluster {{ cluster }} auth get {{ item.name }}"
|
|
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
|
|
|
|
with_items: "{{ keys }}"
|
|
|
|
|
register: keys_exist
|
|
|
|
|
|
|
|
|
|
- name: add key(s) to ceph
|
|
|
|
|
command: "ceph --cluster {{ cluster }} auth import -i /etc/ceph/{{ cluster }}.{{ item.0.name }}.keyring"
|
|
|
|
|
changed_when: false
|
|
|
|
|
with_together:
|
|
|
|
|
- "{{ keys }}"
|
|
|
|
|
- "{{ keys_exist.results }}"
|
|
|
|
|
when: item.1.rc != 0
|
2017-07-20 06:20:18 +08:00
|
|
|
|
|
|
|
|
|
- name: setfacl for key(s)
|
|
|
|
|
acl:
|
|
|
|
|
path: "/etc/ceph/{{ cluster }}.{{ item.0.name }}.keyring"
|
|
|
|
|
entry: "{{ item.1 }}"
|
|
|
|
|
state: present
|
|
|
|
|
with_subelements:
|
|
|
|
|
- "{{ keys }}"
|
|
|
|
|
- acls
|
|
|
|
|
- skip_missing: true
|
|
|
|
|
when:
|
|
|
|
|
- cephx
|
|
|
|
|
- keys | length > 0
|