Using execution_environment option in ad_hoc_command module (#14105)

This commit is contained in:
Akira Yokochi
2023-06-23 02:10:01 +09:00
committed by GitHub
parent 721a2002dc
commit 66f14bfe8f
2 changed files with 36 additions and 0 deletions

View File

@@ -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 }}"