Adding params option into the yumrepo module

This commit is contained in:
Jiri Tyr 2015-12-21 15:56:54 +00:00
parent 1ae3b6a020
commit 7f918b375f

View file

@ -172,6 +172,12 @@ options:
required: true
description:
- Unique repository ID.
params:
required: false
default: None
description:
- Option used to allow the user to overwrite any of the other options. To
remove an option, set the value of the option to C(null).
password:
required: false
default: None
@ -327,6 +333,25 @@ EXAMPLES = '''
name: epel
file: external_repos
state: absent
#
# Allow to overwrite the yumrepo parameters by defining the parameters
# as a variable in the defaults or vars file:
#
# my_role_somerepo_params:
# # Disable GPG checking
# gpgcheck: no
# # Remove the gpgkey option
# gpgkey: null
#
- name: Add Some repo
yumrepo:
name: somerepo
description: Some YUM repo
baseurl: http://server.com/path/to/the/repo
gpgkey: http://server.com/keys/somerepo.pub
gpgcheck: yes
params: "{{ my_role_somerepo_params }}"
'''
RETURN = '''
@ -491,6 +516,7 @@ def main():
mirrorlist=dict(),
mirrorlist_expire=dict(),
name=dict(required=True),
params=dict(),
password=dict(no_log=True),
protect=dict(type='bool'),
proxy=dict(),
@ -514,6 +540,12 @@ def main():
supports_check_mode=True,
)
# Update module parameters by user's parameters if defined
if 'params' in module.params and isinstance(module.params['params'], dict):
module.params.update(module.params['params'])
# Remove the params
module.params.pop('params', None)
name = module.params['name']
state = module.params['state']