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 required: true
description: description:
- Unique repository ID. - 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: password:
required: false required: false
default: None default: None
@ -284,7 +290,7 @@ options:
- Username to use for basic authentication to a repo or really any url. - Username to use for basic authentication to a repo or really any url.
extends_documentation_fragment: extends_documentation_fragment:
- files - files
notes: notes:
- All comments will be removed if modifying an existing repo file. - All comments will be removed if modifying an existing repo file.
@ -327,6 +333,25 @@ EXAMPLES = '''
name: epel name: epel
file: external_repos file: external_repos
state: absent 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 = ''' RETURN = '''
@ -491,6 +516,7 @@ def main():
mirrorlist=dict(), mirrorlist=dict(),
mirrorlist_expire=dict(), mirrorlist_expire=dict(),
name=dict(required=True), name=dict(required=True),
params=dict(),
password=dict(no_log=True), password=dict(no_log=True),
protect=dict(type='bool'), protect=dict(type='bool'),
proxy=dict(), proxy=dict(),
@ -514,6 +540,12 @@ def main():
supports_check_mode=True, 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'] name = module.params['name']
state = module.params['state'] state = module.params['state']