2018-03-30 22:56:44 +08:00
|
|
|
---
|
|
|
|
# This playbook is used to manage CephX Keys
|
|
|
|
# You will find examples below on how the module can be used on daily operations
|
|
|
|
#
|
|
|
|
# It currently runs on localhost
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: CephX key management examples
|
|
|
|
hosts: localhost
|
2018-03-30 22:56:44 +08:00
|
|
|
gather_facts: false
|
|
|
|
vars:
|
|
|
|
cluster: ceph
|
2019-05-14 20:51:32 +08:00
|
|
|
container_exec_cmd: "docker exec ceph-nano"
|
2018-03-30 22:56:44 +08:00
|
|
|
keys_to_info:
|
|
|
|
- client.admin
|
|
|
|
- mds.0
|
|
|
|
keys_to_delete:
|
|
|
|
- client.leseb
|
|
|
|
- client.leseb1
|
|
|
|
- client.pythonnnn
|
|
|
|
keys_to_create:
|
2024-02-14 18:14:02 +08:00
|
|
|
- { name: client.pythonnnn, caps: { mon: "allow rwx", mds: "allow *" }, mode: "0600" }
|
|
|
|
- { name: client.existpassss, caps: { mon: "allow r", osd: "allow *" }, mode: "0600" }
|
|
|
|
- { name: client.path, caps: { mon: "allow r", osd: "allow *" }, mode: "0600" }
|
2018-03-30 22:56:44 +08:00
|
|
|
|
|
|
|
tasks:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create ceph key(s) module
|
2018-03-30 22:56:44 +08:00
|
|
|
ceph_key:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
caps: "{{ item.caps }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
secret: "{{ item.key | default('') }}"
|
2019-05-14 20:51:32 +08:00
|
|
|
containerized: "{{ container_exec_cmd | default(False) }}"
|
2018-03-30 22:56:44 +08:00
|
|
|
with_items: "{{ keys_to_create }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Update ceph key(s)
|
2018-03-30 22:56:44 +08:00
|
|
|
ceph_key:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
state: update
|
|
|
|
caps: "{{ item.caps }}"
|
|
|
|
cluster: "{{ cluster }}"
|
2019-05-14 20:51:32 +08:00
|
|
|
containerized: "{{ container_exec_cmd | default(False) }}"
|
2018-03-30 22:56:44 +08:00
|
|
|
with_items: "{{ keys_to_create }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Delete ceph key(s)
|
2018-03-30 22:56:44 +08:00
|
|
|
ceph_key:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
cluster: "{{ cluster }}"
|
2019-05-14 20:51:32 +08:00
|
|
|
containerized: "{{ container_exec_cmd | default(False) }}"
|
2018-03-30 22:56:44 +08:00
|
|
|
with_items: "{{ keys_to_delete }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Info ceph key(s)
|
2018-03-30 22:56:44 +08:00
|
|
|
ceph_key:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: info
|
|
|
|
cluster: "{{ cluster }}"
|
2019-05-14 20:51:32 +08:00
|
|
|
containerized: "{{ container_exec_cmd }}"
|
2018-03-30 22:56:44 +08:00
|
|
|
register: key_info
|
|
|
|
ignore_errors: true
|
|
|
|
with_items: "{{ keys_to_info }}"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: List ceph key(s)
|
2018-03-30 22:56:44 +08:00
|
|
|
ceph_key:
|
|
|
|
state: list
|
|
|
|
cluster: "{{ cluster }}"
|
2019-05-14 20:51:32 +08:00
|
|
|
containerized: "{{ container_exec_cmd | default(False) }}"
|
2018-03-30 22:56:44 +08:00
|
|
|
register: list_keys
|
|
|
|
ignore_errors: true
|
2018-10-24 00:38:40 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Fetch_initial_keys # noqa: ignore-errors
|
2018-10-24 00:38:40 +08:00
|
|
|
ceph_key:
|
|
|
|
state: fetch_initial_keys
|
|
|
|
cluster: "{{ cluster }}"
|
2019-08-23 02:29:40 +08:00
|
|
|
ignore_errors: true
|