diff options
-rw-r--r-- | awx_collection/plugins/modules/tower_job_launch.py | 30 | ||||
-rw-r--r-- | awx_collection/tests/integration/targets/tower_job_launch/tasks/main.yml | 6 |
2 files changed, 27 insertions, 9 deletions
diff --git a/awx_collection/plugins/modules/tower_job_launch.py b/awx_collection/plugins/modules/tower_job_launch.py index d1e47c9b68..801a4cfc85 100644 --- a/awx_collection/plugins/modules/tower_job_launch.py +++ b/awx_collection/plugins/modules/tower_job_launch.py @@ -176,22 +176,34 @@ def main(): optional_args = {} # Extract our parameters name = module.params.get('name') - optional_args['job_type'] = module.params.get('job_type') inventory = module.params.get('inventory') organization = module.params.get('organization') credentials = module.params.get('credentials') - optional_args['limit'] = module.params.get('limit') - optional_args['tags'] = module.params.get('tags') - optional_args['extra_vars'] = module.params.get('extra_vars') - optional_args['scm_branch'] = module.params.get('scm_branch') - optional_args['skip_tags'] = module.params.get('skip_tags') - optional_args['verbosity'] = module.params.get('verbosity') - optional_args['diff_mode'] = module.params.get('diff_mode') - optional_args['credential_passwords'] = module.params.get('credential_passwords') wait = module.params.get('wait') interval = module.params.get('interval') timeout = module.params.get('timeout') + for field_name in ( + 'job_type', + 'limit', + 'extra_vars', + 'scm_branch', + 'verbosity', + 'diff_mode', + 'credential_passwords', + ): + field_val = module.params.get(field_name) + if field_val is not None: + optional_args[field_name] = field_val + + # Special treatment of tags parameters + job_tags = module.params.get('tags') + if job_tags is not None: + optional_args['job_tags'] = ",".join(job_tags) + skip_tags = module.params.get('skip_tags') + if skip_tags is not None: + optional_args['skip_tags'] = ",".join(skip_tags) + # Create a datastructure to pass into our job launch post_data = {} for key in optional_args.keys(): diff --git a/awx_collection/tests/integration/targets/tower_job_launch/tasks/main.yml b/awx_collection/tests/integration/targets/tower_job_launch/tasks/main.yml index 4599682fbf..30fa8cc13b 100644 --- a/awx_collection/tests/integration/targets/tower_job_launch/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_job_launch/tasks/main.yml @@ -48,6 +48,8 @@ job_type: run ask_credential: true ask_inventory: true + ask_tags_on_launch: true + ask_skip_tags_on_launch: true state: present register: result @@ -56,6 +58,10 @@ job_template: "{{ jt_name1 }}" inventory: "Demo Inventory" credential: "Demo Credential" + tags: + - sometimes + skip_tags: + - always register: result - assert: |