mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
Using execution_environment option in ad_hoc_command module (#14105)
This commit is contained in:
parent
721a2002dc
commit
66f14bfe8f
@ -145,6 +145,7 @@ def main():
|
||||
wait = module.params.get('wait')
|
||||
interval = module.params.get('interval')
|
||||
timeout = module.params.get('timeout')
|
||||
execution_environment = module.params.get('execution_environment')
|
||||
|
||||
# Create a datastructure to pass into our command launch
|
||||
post_data = {
|
||||
@ -158,6 +159,8 @@ def main():
|
||||
# Attempt to look up the related items the user specified (these will fail the module if not found)
|
||||
post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
||||
post_data['credential'] = module.resolve_name_to_id('credentials', credential)
|
||||
if execution_environment:
|
||||
post_data['execution_environment'] = module.resolve_name_to_id('execution_environments', execution_environment)
|
||||
|
||||
# Launch the ad hoc command
|
||||
results = module.post_endpoint('ad_hoc_commands', **{'data': post_data})
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
inv_name: "AWX-Collection-tests-ad_hoc_command-inventory-{{ test_id }}"
|
||||
ssh_cred_name: "AWX-Collection-tests-ad_hoc_command-ssh-cred-{{ test_id }}"
|
||||
org_name: "AWX-Collection-tests-ad_hoc_command-org-{{ test_id }}"
|
||||
ee_name: "AWX-Collection-tests-ad_hoc_command-ee-{{ test_id }}"
|
||||
|
||||
- name: Create a New Organization
|
||||
organization:
|
||||
@ -34,6 +35,16 @@
|
||||
credential_type: 'Machine'
|
||||
state: present
|
||||
|
||||
- name: Create an Execution Environment
|
||||
execution_environment:
|
||||
name: "{{ ee_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
description: "EE for Testing"
|
||||
image: quay.io/ansible/awx-ee
|
||||
pull: always
|
||||
state: present
|
||||
register: result_ee
|
||||
|
||||
- name: Launch an Ad Hoc Command waiting for it to finish
|
||||
ad_hoc_command:
|
||||
inventory: "{{ inv_name }}"
|
||||
@ -61,6 +72,21 @@
|
||||
- "result is changed"
|
||||
- "result.status == 'successful'"
|
||||
|
||||
- name: Launch an Ad Hoc Command with Execution Environment specified
|
||||
ad_hoc_command:
|
||||
inventory: "Demo Inventory"
|
||||
credential: "{{ ssh_cred_name }}"
|
||||
execution_environment: "{{ ee_name }}"
|
||||
module_name: "ping"
|
||||
wait: true
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
- "result.status == 'successful'"
|
||||
- "lookup('awx.awx.controller_api', 'ad_hoc_commands/' ~ result.id)['execution_environment'] == result_ee.id"
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
ad_hoc_command:
|
||||
inventory: "{{ inv_name }}"
|
||||
@ -75,6 +101,13 @@
|
||||
- "result is not changed"
|
||||
- "'Does not exist' in result.response['json']['module_name'][0]"
|
||||
|
||||
- name: Delete the Execution Environment
|
||||
execution_environment:
|
||||
name: "{{ ee_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
image: quay.io/ansible/awx-ee
|
||||
state: absent
|
||||
|
||||
- name: Delete the Credential
|
||||
credential:
|
||||
name: "{{ ssh_cred_name }}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user