ceph_key: set state as optional

Most ansible module using a state parameter default to the present
value (when available) instead of using it as a mandatory option.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit abb4023d76)
pull/5788/head
Dimitri Savineau 2020-09-11 09:34:05 -04:00 committed by Dimitri Savineau
parent e785654632
commit 23522a11e4
9 changed files with 6 additions and 15 deletions

View File

@ -25,7 +25,6 @@
- name: create ceph key(s) module - name: create ceph key(s) module
ceph_key: ceph_key:
name: "{{ item.name }}" name: "{{ item.name }}"
state: present
caps: "{{ item.caps }}" caps: "{{ item.caps }}"
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
secret: "{{ item.key | default('') }}" secret: "{{ item.key | default('') }}"

View File

@ -167,7 +167,6 @@
- name: create potentially missing keys (rbd and rbd-mirror) - name: create potentially missing keys (rbd and rbd-mirror)
ceph_key: ceph_key:
name: "client.{{ item.0 }}" name: "client.{{ item.0 }}"
state: present
dest: "/var/lib/ceph/{{ item.0 }}/" dest: "/var/lib/ceph/{{ item.0 }}/"
caps: caps:
mon: "allow profile {{ item.0 }}" mon: "allow profile {{ item.0 }}"

View File

@ -59,9 +59,9 @@ options:
return a json output. return a json output.
If 'info' is used, the module will return in a json format the If 'info' is used, the module will return in a json format the
description of a given keyring. description of a given keyring.
required: true required: false
choices: ['present', 'absent', 'list', 'info'] choices: ['present', 'update', 'absent', 'list', 'info', 'fetch_initial_keys']
default: list default: present
caps: caps:
description: description:
- CephX key capabilities - CephX key capabilities
@ -498,7 +498,7 @@ def run_module():
module_args = dict( module_args = dict(
cluster=dict(type='str', required=False, default='ceph'), cluster=dict(type='str', required=False, default='ceph'),
name=dict(type='str', required=False), name=dict(type='str', required=False),
state=dict(type='str', required=True), state=dict(type='str', required=False, default='present', choices=['present', 'update', 'absent', 'list', 'info', 'fetch_initial_keys']),
caps=dict(type='dict', required=False, default=None), caps=dict(type='dict', required=False, default=None),
secret=dict(type='str', required=False, default=None), secret=dict(type='str', required=False, default=None),
import_key=dict(type='bool', required=False, default=True), import_key=dict(type='bool', required=False, default=True),

View File

@ -52,9 +52,9 @@ options:
If 'absent' is used, the module will simply delete the pool. If 'absent' is used, the module will simply delete the pool.
If 'list' is used, the module will return all details about the existing pools If 'list' is used, the module will return all details about the existing pools
(json formatted). (json formatted).
required: true required: false
choices: ['present', 'absent', 'list'] choices: ['present', 'absent', 'list']
default: list default: present
size: size:
description: description:
- set the replica size of the pool. - set the replica size of the pool.

View File

@ -75,7 +75,6 @@
- name: create ceph pool(s) - name: create ceph pool(s)
ceph_pool: ceph_pool:
name: "{{ item.name }}" name: "{{ item.name }}"
state: present
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
pg_num: "{{ item.pg_num | default(osd_pool_default_pg_num) if not item.0.pg_autoscale_mode | default(False) | bool else 16 }}" pg_num: "{{ item.pg_num | default(osd_pool_default_pg_num) if not item.0.pg_autoscale_mode | default(False) | bool else 16 }}"
pgp_num: "{{ item.pgp_num | default(item.pg_num) | default(osd_pool_default_pg_num) if not item.pg_autoscale_mode | default(False) | bool else omit }}" pgp_num: "{{ item.pgp_num | default(item.pg_num) | default(osd_pool_default_pg_num) if not item.pg_autoscale_mode | default(False) | bool else omit }}"

View File

@ -4,7 +4,6 @@
block: block:
- name: create client.crash keyring - name: create client.crash keyring
ceph_key: ceph_key:
state: present
name: "client.crash" name: "client.crash"
caps: "{{ {'mon': 'allow profile crash', 'mgr': 'allow profile crash'} }}" caps: "{{ {'mon': 'allow profile crash', 'mgr': 'allow profile crash'} }}"
cluster: "{{ cluster }}" cluster: "{{ cluster }}"

View File

@ -10,7 +10,6 @@
- name: fetch ceph mgr keyring - name: fetch ceph mgr keyring
ceph_key: ceph_key:
name: "mgr.{{ ansible_hostname }}" name: "mgr.{{ ansible_hostname }}"
state: present
caps: caps:
mon: allow profile mgr mon: allow profile mgr
osd: allow * osd: allow *
@ -32,7 +31,6 @@
- name: create ceph mgr keyring(s) on a mon node - name: create ceph mgr keyring(s) on a mon node
ceph_key: ceph_key:
name: "mgr.{{ hostvars[item]['ansible_hostname'] }}" name: "mgr.{{ hostvars[item]['ansible_hostname'] }}"
state: present
caps: caps:
mon: allow profile mgr mon: allow profile mgr
osd: allow * osd: allow *

View File

@ -29,7 +29,6 @@
- name: create monitor initial keyring - name: create monitor initial keyring
ceph_key: ceph_key:
name: mon. name: mon.
state: present
dest: "/var/lib/ceph/tmp/" dest: "/var/lib/ceph/tmp/"
secret: "{{ monitor_keyring }}" secret: "{{ monitor_keyring }}"
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
@ -62,7 +61,6 @@
- name: create custom admin keyring - name: create custom admin keyring
ceph_key: ceph_key:
name: client.admin name: client.admin
state: present
secret: "{{ admin_secret }}" secret: "{{ admin_secret }}"
caps: "{{ client_admin_ceph_authtool_cap }}" caps: "{{ client_admin_ceph_authtool_cap }}"
import_key: False import_key: False

View File

@ -25,7 +25,6 @@
block: block:
- name: generate keys - name: generate keys
ceph_key: ceph_key:
state: present
name: "{{ item.name }}" name: "{{ item.name }}"
caps: "{{ item.caps }}" caps: "{{ item.caps }}"
secret: "{{ item.key | default('') }}" secret: "{{ item.key | default('') }}"