mirror of https://github.com/ceph/ceph-ansible.git
library: add realm pull to radosgw_realm module
This adds the realm pull operation to the current radosgw_realm module. The pull operation requires the url, access/secret key variables. Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>debug_update_nfs_version
parent
2437f14581
commit
5b86ac8801
|
@ -61,6 +61,18 @@ options:
|
||||||
- set the default flag on the realm.
|
- set the default flag on the realm.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
url:
|
||||||
|
description:
|
||||||
|
- URL to the master RADOS Gateway zone.
|
||||||
|
required: false
|
||||||
|
access_key:
|
||||||
|
description:
|
||||||
|
- S3 access key of the master RADOS Gateway zone.
|
||||||
|
required: false
|
||||||
|
secret_key:
|
||||||
|
description:
|
||||||
|
- S3 secret key of the master RADOS Gateway zone.
|
||||||
|
required: false
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Dimitri Savineau <dsavinea@redhat.com>
|
- Dimitri Savineau <dsavinea@redhat.com>
|
||||||
|
@ -205,6 +217,24 @@ def remove_realm(module, container_image=None):
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
def pull_realm(module, container_image=None):
|
||||||
|
'''
|
||||||
|
Pull a realm
|
||||||
|
'''
|
||||||
|
|
||||||
|
cluster = module.params.get('cluster')
|
||||||
|
name = module.params.get('name')
|
||||||
|
url = module.params.get('url')
|
||||||
|
access_key = module.params.get('access_key')
|
||||||
|
secret_key = module.params.get('secret_key')
|
||||||
|
|
||||||
|
args = ['pull', '--rgw-realm=' + name, '--url=' + url, '--access-key=' + access_key, '--secret=' + secret_key]
|
||||||
|
|
||||||
|
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def exit_module(module, out, rc, cmd, err, startd, changed=False):
|
def exit_module(module, out, rc, cmd, err, startd, changed=False):
|
||||||
endd = datetime.datetime.now()
|
endd = datetime.datetime.now()
|
||||||
delta = endd - startd
|
delta = endd - startd
|
||||||
|
@ -226,13 +256,17 @@ 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=True),
|
name=dict(type='str', required=True),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info', 'pull'], default='present'),
|
||||||
default=dict(type='bool', required=False, default=False),
|
default=dict(type='bool', required=False, default=False),
|
||||||
|
url=dict(type='str', required=False),
|
||||||
|
access_key=dict(type='str', required=False),
|
||||||
|
secret_key=dict(type='str', required=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=module_args,
|
argument_spec=module_args,
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
|
required_if=[['state', 'pull', ['url', 'access_key', 'secret_key']]],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Gather module parameters in variables
|
# Gather module parameters in variables
|
||||||
|
@ -274,6 +308,9 @@ def run_module():
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_commands(module, get_realm(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_realm(module, container_image=container_image))
|
||||||
|
|
||||||
|
elif state == "pull":
|
||||||
|
rc, cmd, out, err = exec_commands(module, pull_realm(module, container_image=container_image))
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,20 @@
|
||||||
when: not item.rgw_zonemaster | default(rgw_zonemaster) | bool
|
when: not item.rgw_zonemaster | default(rgw_zonemaster) | bool
|
||||||
|
|
||||||
- name: fetch the realm(s)
|
- name: fetch the realm(s)
|
||||||
command: "{{ container_exec_cmd }} radosgw-admin realm pull --cluster={{ cluster }} --rgw-realm={{ item.realm }} --url={{ item.endpoint }} --access-key={{ item.system_access_key }} --secret={{ item.system_secret_key }}"
|
radosgw_realm:
|
||||||
|
name: "{{ item.realm }}"
|
||||||
|
cluster: "{{ cluster }}"
|
||||||
|
url: "{{ item.endpoint }}"
|
||||||
|
access_key: "{{ item.system_access_key }}"
|
||||||
|
secret_key: "{{ item.system_secret_key }}"
|
||||||
|
state: pull
|
||||||
delegate_to: "{{ groups[mon_group_name][0] }}"
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
||||||
run_once: true
|
run_once: true
|
||||||
loop: "{{ secondary_realms }}"
|
loop: "{{ secondary_realms }}"
|
||||||
when: secondary_realms is defined
|
when: secondary_realms is defined
|
||||||
|
environment:
|
||||||
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
||||||
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
||||||
|
|
||||||
- name: get the period(s)
|
- name: get the period(s)
|
||||||
command: "{{ container_exec_cmd }} radosgw-admin period get --cluster={{ cluster }} --rgw-realm={{ item.realm }}"
|
command: "{{ container_exec_cmd }} radosgw-admin period get --cluster={{ cluster }} --rgw-realm={{ item.realm }}"
|
||||||
|
|
|
@ -25,6 +25,9 @@ fake_realm = 'foo'
|
||||||
fake_params = {'cluster': fake_cluster,
|
fake_params = {'cluster': fake_cluster,
|
||||||
'name': fake_realm,
|
'name': fake_realm,
|
||||||
'default': True}
|
'default': True}
|
||||||
|
fake_url = 'http://192.168.42.100:8080'
|
||||||
|
fake_access_key = '8XQHmFxixz7LCM2AdM2p'
|
||||||
|
fake_secret_key = 'XC8IhEPJprL6SrpaJDmolVs7jbOvoe2E3AaWKGRx'
|
||||||
|
|
||||||
|
|
||||||
class TestRadosgwRealmModule(object):
|
class TestRadosgwRealmModule(object):
|
||||||
|
@ -103,3 +106,19 @@ class TestRadosgwRealmModule(object):
|
||||||
]
|
]
|
||||||
|
|
||||||
assert radosgw_realm.remove_realm(fake_module) == expected_cmd
|
assert radosgw_realm.remove_realm(fake_module) == expected_cmd
|
||||||
|
|
||||||
|
def test_pull_realm(self):
|
||||||
|
fake_module = MagicMock()
|
||||||
|
fake_params.update({'url': fake_url, 'access_key': fake_access_key, 'secret_key': fake_secret_key})
|
||||||
|
fake_module.params = fake_params
|
||||||
|
expected_cmd = [
|
||||||
|
fake_binary,
|
||||||
|
'--cluster', fake_cluster,
|
||||||
|
'realm', 'pull',
|
||||||
|
'--rgw-realm=' + fake_realm,
|
||||||
|
'--url=' + fake_url,
|
||||||
|
'--access-key=' + fake_access_key,
|
||||||
|
'--secret=' + fake_secret_key
|
||||||
|
]
|
||||||
|
|
||||||
|
assert radosgw_realm.pull_realm(fake_module) == expected_cmd
|
||||||
|
|
Loading…
Reference in New Issue