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-09-02 09:30:04 +08:00
|
|
|
|
when:
|
|
|
|
|
- pools | length > 0
|
|
|
|
|
- copy_admin_key
|
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
|
2017-09-02 09:30:04 +08:00
|
|
|
|
when:
|
|
|
|
|
- copy_admin_key
|
2017-07-13 23:39:35 +08:00
|
|
|
|
|
|
|
|
|
- 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 }}"
|
2017-09-02 09:30:04 +08:00
|
|
|
|
- "{{ keys_exist.results | default([]) }}"
|
|
|
|
|
when:
|
|
|
|
|
- not item.1.get("skipped")
|
|
|
|
|
- copy_admin_key
|
|
|
|
|
- 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
|
2017-08-10 04:52:18 +08:00
|
|
|
|
|
|
|
|
|
- name: chmod key(s)
|
|
|
|
|
file:
|
|
|
|
|
path: "/etc/ceph/{{ cluster }}.{{ item.name }}.keyring"
|
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
|
with_items: "{{ keys }}"
|
|
|
|
|
when:
|
|
|
|
|
- cephx
|
|
|
|
|
- keys | length > 0
|