mirror of
https://github.com/ZwareBear/awx.git
synced 2026-03-20 07:43:35 -05:00
fixup return values for bulk launch and host create in awxkit
Enabled the params bulk job make black make black again Fixed inventory and organization input params for bulk modules add collection integration tests Fix cli return errors fix test completeness
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
---
|
||||
- name: Generate a random string for test
|
||||
set_fact:
|
||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
when: test_id is not defined
|
||||
|
||||
- name: Generate a unique name
|
||||
set_fact:
|
||||
bulk_host_name: "AWX-Collection-tests-bulk_host_create-{{ test_id }}"
|
||||
|
||||
- name: Get our collection package
|
||||
controller_meta:
|
||||
register: controller_meta
|
||||
|
||||
- name: Generate the name of our plugin
|
||||
set_fact:
|
||||
plugin_name: "{{ controller_meta.prefix }}.controller_api"
|
||||
|
||||
|
||||
- name: Create an inventory
|
||||
inventory:
|
||||
name: "{{ bulk_host_name }}"
|
||||
organization: Default
|
||||
state: present
|
||||
register: inventory_result
|
||||
|
||||
|
||||
- name: Bulk Host Create
|
||||
bulk_host_create:
|
||||
hosts:
|
||||
- name: "123.456.789.123"
|
||||
description: "myhost1"
|
||||
variables:
|
||||
food: carrot
|
||||
color: orange
|
||||
- name: example.dns.gg
|
||||
description: "myhost2"
|
||||
enabled: false
|
||||
inventory: "{{ inventory_result.id }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is not failed
|
||||
|
||||
# cleanup
|
||||
- name: Delete inventory
|
||||
inventory:
|
||||
name: "{{ bulk_host_name }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
- name: Generate a random string for test
|
||||
set_fact:
|
||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
when: test_id is not defined
|
||||
|
||||
- name: Generate a unique name
|
||||
set_fact:
|
||||
bulk_job_name: "AWX-Collection-tests-bulk_job_launch-{{ test_id }}"
|
||||
|
||||
- name: Get our collection package
|
||||
controller_meta:
|
||||
register: controller_meta
|
||||
|
||||
- name: Generate the name of our plugin
|
||||
set_fact:
|
||||
plugin_name: "{{ controller_meta.prefix }}.controller_api"
|
||||
|
||||
- name: Get Inventory
|
||||
set_fact:
|
||||
inventory_id: "{{ lookup(plugin_name, 'inventories', query_params={'name': 'Demo Inventory'}, return_ids=True ) }}"
|
||||
|
||||
- name: Create a Job Template
|
||||
job_template:
|
||||
name: "{{ bulk_job_name }}"
|
||||
copy_from: "Demo Job Template"
|
||||
ask_variables_on_launch: true
|
||||
ask_inventory_on_launch: true
|
||||
ask_skip_tags_on_launch: true
|
||||
allow_simultaneous: true
|
||||
state: present
|
||||
register: jt_result
|
||||
|
||||
- name: Create Bulk Job
|
||||
bulk_job_launch:
|
||||
name: "{{ bulk_job_name }}"
|
||||
jobs:
|
||||
- unified_job_template: "{{ jt_result.id }}"
|
||||
inventory: "{{ inventory_id }}"
|
||||
skip_tags: "skipfoo,skipbar"
|
||||
extra_data:
|
||||
animal: fish
|
||||
color: orange
|
||||
- unified_job_template: "{{ jt_result.id }}"
|
||||
extra_vars:
|
||||
animal: bear
|
||||
food: carrot
|
||||
skip_tags: "skipbaz"
|
||||
job_tags: "Hello World"
|
||||
limit: "localhost"
|
||||
wait: False
|
||||
inventory: "{{ inventory_id }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is not failed
|
||||
- "'id' in result"
|
||||
- result['job_info']['skip_tags'] == "skipbaz"
|
||||
- result['job_info']['limit'] == "localhost"
|
||||
- result['job_info']['job_tags'] == "Hello World"
|
||||
- result['job_info']['inventory'] == {{ inventory_id }}
|
||||
- "result['job_info']['extra_vars'] == '{\"animal\": \"bear\", \"food\": \"carrot\"}'"
|
||||
|
||||
# cleanup
|
||||
- name: Delete Job Template
|
||||
job_template:
|
||||
name: "{{ bulk_job_name }}"
|
||||
state: absent
|
||||
Reference in New Issue
Block a user