summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Roux <pierre.roux01@gmail.com>2018-05-26 01:03:12 +0200
committerAdam Miller <admiller@redhat.com>2018-05-25 18:03:12 -0500
commit81de7582d9fd4d514857eb4af748dc60445cf3f6 (patch)
tree67b2014effd512d6e4f80d7274cdef550cae9463
parentc4536bc827e4b8faeb5faefc088159ac2bfe07d2 (diff)
downloadansible-81de7582d9fd4d514857eb4af748dc60445cf3f6.tar.gz
Fix tower_* modules **params kwargs (#40137)
* Add cleaning function to handle **params The cleaning function is only added to tower modules which pass a `**params` argument as an unpacked dictionnary to the tower-cli method calls. Fix #39745 * Remove previous code added only for tower_role In 872a7b4, the `update_resources` function was modified so that it would clear unwanted parameters. However, this behaviour is desired for other modules too, modified in another commit. (see tower_clean_params).
-rw-r--r--lib/ansible/module_utils/ansible_tower.py10
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py6
4 files changed, 8 insertions, 12 deletions
diff --git a/lib/ansible/module_utils/ansible_tower.py b/lib/ansible/module_utils/ansible_tower.py
index eab1bac3b9..690df47609 100644
--- a/lib/ansible/module_utils/ansible_tower.py
+++ b/lib/ansible/module_utils/ansible_tower.py
@@ -45,7 +45,7 @@ def tower_auth_config(module):
it will attempt to fetch values from the module pararms and
only pass those values that have been set.
'''
- config_file = module.params.get('tower_config_file')
+ config_file = module.params.pop('tower_config_file', None)
if config_file:
config_file = os.path.expanduser(config_file)
if not os.path.exists(config_file):
@@ -57,16 +57,16 @@ def tower_auth_config(module):
return parser.string_to_dict(f.read())
else:
auth_config = {}
- host = module.params.get('tower_host')
+ host = module.params.pop('tower_host', None)
if host:
auth_config['host'] = host
- username = module.params.get('tower_username')
+ username = module.params.pop('tower_username', None)
if username:
auth_config['username'] = username
- password = module.params.get('tower_password')
+ password = module.params.pop('tower_password', None)
if password:
auth_config['password'] = password
- verify_ssl = module.params.get('tower_verify_ssl')
+ verify_ssl = module.params.pop('tower_verify_ssl', None)
if verify_ssl is not None:
auth_config['verify_ssl'] = verify_ssl
return auth_config
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py
index 7818c92b04..04180e08d6 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py
@@ -134,7 +134,7 @@ def main():
name = module.params.get('name')
inventory = module.params.get('inventory')
credential = module.params.get('credential')
- state = module.params.get('state')
+ state = module.params.pop('state')
variables = module.params.get('variables')
if variables:
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py
index 703db940d9..8c9cd2560a 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py
@@ -222,7 +222,7 @@ def main():
module.fail_json(msg='ansible-tower-cli required for this module')
name = module.params.get('name')
- state = module.params.get('state')
+ state = module.params.pop('state')
json_output = {'job_template': name, 'state': state}
tower_auth = tower_auth_config(module)
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py
index 096f6173f5..95cc59f036 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py
@@ -87,10 +87,6 @@ def update_resources(module, p):
by name using their unique field (identity)
'''
params = p.copy()
- for key in p:
- if key.startswith('tower_'):
- params.pop(key)
- params.pop('state', None)
identity_map = {
'user': 'username',
'team': 'name',
@@ -134,7 +130,7 @@ def main():
module.fail_json(msg='ansible-tower-cli required for this module')
role_type = module.params.pop('role')
- state = module.params.get('state')
+ state = module.params.pop('state')
json_output = {'role': role_type, 'state': state}