mirror of
https://github.com/ZwareBear/awx.git
synced 2026-03-27 03:03:37 -05:00
112 lines
3.2 KiB
YAML
112 lines
3.2 KiB
YAML
---
|
|
- 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 names
|
|
set_fact:
|
|
org_name1: "AWX-Collection-tests-export-organization-{{ test_id }}"
|
|
org_name2: "AWX-Collection-tests-export-organization2-{{ test_id }}"
|
|
inventory_name1: "AWX-Collection-tests-export-inv1-{{ test_id }}"
|
|
|
|
- block:
|
|
- name: Create some organizations
|
|
organization:
|
|
name: "{{ item }}"
|
|
loop:
|
|
- "{{ org_name1 }}"
|
|
- "{{ org_name2 }}"
|
|
|
|
- name: Create an inventory
|
|
inventory:
|
|
name: "{{ inventory_name1 }}"
|
|
organization: "{{ org_name1 }}"
|
|
|
|
- name: Export all assets
|
|
export:
|
|
all: true
|
|
register: all_assets
|
|
|
|
- assert:
|
|
that:
|
|
- all_assets is not changed
|
|
- all_assets is successful
|
|
- all_assets['assets']['organizations'] | length() >= 2
|
|
|
|
- name: Export all inventories
|
|
export:
|
|
inventory: 'all'
|
|
register: inventory_export
|
|
|
|
- assert:
|
|
that:
|
|
- inventory_export is successful
|
|
- inventory_export is not changed
|
|
- inventory_export['assets']['inventory'] | length() >= 1
|
|
- "'organizations' not in inventory_export['assets']"
|
|
|
|
# This mimics the example in the module
|
|
- name: Export an all and a specific
|
|
export:
|
|
inventory: 'all'
|
|
organizations: "{{ org_name1 }}"
|
|
register: mixed_export
|
|
|
|
- assert:
|
|
that:
|
|
- mixed_export is successful
|
|
- mixed_export is not changed
|
|
- mixed_export['assets']['inventory'] | length() >= 1
|
|
- mixed_export['assets']['organizations'] | length() == 1
|
|
- "'workflow_job_templates' not in mixed_export['assets']"
|
|
|
|
- name: Export list of organizations
|
|
export:
|
|
organizations: "{{[org_name1, org_name2]}}"
|
|
register: list_asserts
|
|
|
|
- assert:
|
|
that:
|
|
- list_asserts is not changed
|
|
- list_asserts is successful
|
|
- list_asserts['assets']['organizations'] | length() >= 2
|
|
|
|
- name: Export list with one organization
|
|
export:
|
|
organizations: "{{[org_name1]}}"
|
|
register: list_asserts
|
|
|
|
- assert:
|
|
that:
|
|
- list_asserts is not changed
|
|
- list_asserts is successful
|
|
- list_asserts['assets']['organizations'] | length() >= 1
|
|
- "org_name1 in (list_asserts['assets']['organizations'] | map(attribute='name') )"
|
|
|
|
- name: Export one organization as string
|
|
export:
|
|
organizations: "{{org_name2}}"
|
|
register: string_asserts
|
|
|
|
- assert:
|
|
that:
|
|
- string_asserts is not changed
|
|
- string_asserts is successful
|
|
- string_asserts['assets']['organizations'] | length() >= 1
|
|
- "org_name2 in (string_asserts['assets']['organizations'] | map(attribute='name') )"
|
|
always:
|
|
- name: Remove our inventory
|
|
inventory:
|
|
name: "{{ inventory_name1 }}"
|
|
organization: "{{ org_name1 }}"
|
|
state: absent
|
|
|
|
- name: Remove test organizations
|
|
organization:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- "{{ org_name1 }}"
|
|
- "{{ org_name2 }}"
|