From a79f987765ae7d6ba5763c6d45c56ea7d325ec3f Mon Sep 17 00:00:00 2001 From: Sean Sullivan Date: Sat, 4 Nov 2023 06:42:17 -0500 Subject: [PATCH] constructed inventory source skip (#720) --- .github/workflows/ci_standalone.yml | 8 ++++---- changelogs/fragments/checkmode.yml | 5 +++++ changelogs/fragments/constructed.yml | 4 ++++ roles/inventory_sources/README.md | 2 +- roles/inventory_sources/tasks/main.yml | 1 + tests/configs/differential_items.yml | 3 +++ tests/configs/inventories.yml | 5 +++++ tests/configs/inventory_sources.yml | 4 +++- tests/configs_export_model/differential_items.yml | 4 ++-- tests/configure_controller.yml | 2 -- tests/configure_controller_export_model.yml | 2 -- 11 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 changelogs/fragments/checkmode.yml create mode 100644 changelogs/fragments/constructed.yml diff --git a/.github/workflows/ci_standalone.yml b/.github/workflows/ci_standalone.yml index 38a0ffda6..6040a803d 100644 --- a/.github/workflows/ci_standalone.yml +++ b/.github/workflows/ci_standalone.yml @@ -19,10 +19,10 @@ jobs: matrix: awx_version: - devel - - 22.6.0 - - 22.5.0 - - 21.13.0 - - 21.11.0 + - 23.3.1 + - 23.3.0 + - 23.0.0 + - 22.7.0 uses: "./.github/workflows/ci_standalone_versioned.yml" with: awx_version: ${{ matrix.awx_version }} diff --git a/changelogs/fragments/checkmode.yml b/changelogs/fragments/checkmode.yml new file mode 100644 index 000000000..c4a03a114 --- /dev/null +++ b/changelogs/fragments/checkmode.yml @@ -0,0 +1,5 @@ +--- +minor_changes: + - added mandatory check to workflow launch name option + - added improvements to checkmod where it will run faster with the async tasks. In addition added an additional fail check at end of dispatch that will likely fail if dependencies are missing, as expected. +... diff --git a/changelogs/fragments/constructed.yml b/changelogs/fragments/constructed.yml new file mode 100644 index 000000000..d444c2af7 --- /dev/null +++ b/changelogs/fragments/constructed.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - The role 'inventory_sources' will now skip when the source parameter is `constructed`. These sources are auto created and not meant to be edited. However they can still be synced with the inventory_source_update. +... diff --git a/roles/inventory_sources/README.md b/roles/inventory_sources/README.md index 0a9ba43d8..f225a517a 100644 --- a/roles/inventory_sources/README.md +++ b/roles/inventory_sources/README.md @@ -99,7 +99,7 @@ The role will strip the double space between the curly bracket in order to provi |`description`|`False`|no|The description to use for the inventory source.| |`inventory`|""|yes|Inventory the group should be made a member of.| |`organization`|""|no|Organization the inventory belongs to.| -|`source`|""|no|The source to use for this group.| +|`source`|""|no|The source to use for this group. If set to `constructed` this role will be skipped as they are not meant to be edited.| |`source_path`|""|no|For an SCM based inventory source, the source path points to the file within the repo to use as an inventory.| |`source_vars`|""|no|The variables or environment fields to apply to this source type.| |`enabled_var`|""|no|The variable to use to determine enabled state e.g., "status.power_state".| diff --git a/roles/inventory_sources/tasks/main.yml b/roles/inventory_sources/tasks/main.yml index f057c1701..e778c6333 100644 --- a/roles/inventory_sources/tasks/main.yml +++ b/roles/inventory_sources/tasks/main.yml @@ -46,6 +46,7 @@ poll: 0 register: __inventory_source_job_async changed_when: not __inventory_source_job_async.changed + when: __controller_source_item.source != "constructed" vars: __operation: "{{ operation_translate[__controller_source_item.state | default(controller_state) | default('present')] }}" ansible_async_dir: '{{ controller_configuration_async_dir }}' diff --git a/tests/configs/differential_items.yml b/tests/configs/differential_items.yml index 770b8854c..3cb3c8ed5 100644 --- a/tests/configs/differential_items.yml +++ b/tests/configs/differential_items.yml @@ -106,6 +106,9 @@ differential_items: - name: satlab-admin-inventory organization: Default state: absent + - name: test_constructed + organization: Default + state: absent - name: Test Inventory - Smart organization: Default state: absent diff --git a/tests/configs/inventories.yml b/tests/configs/inventories.yml index e520b0c73..896103673 100644 --- a/tests/configs/inventories.yml +++ b/tests/configs/inventories.yml @@ -22,4 +22,9 @@ controller_inventories: description: created by Ansible Playbook kind: smart host_filter: "name__icontains=localhost" + - name: test_constructed + organization: Default + kind: constructed + input_inventories: + - localhost ... diff --git a/tests/configs/inventory_sources.yml b/tests/configs/inventory_sources.yml index 42a684172..cf0dbf448 100644 --- a/tests/configs/inventory_sources.yml +++ b/tests/configs/inventory_sources.yml @@ -40,5 +40,7 @@ controller_inventory_sources: organization: Satellite source: scm state: absent - # more options can be provided but for scm source we are using, we need only this much. + - name: "Auto-created source for: test_constructed" + inventory: test_constructed + source: constructed ... diff --git a/tests/configs_export_model/differential_items.yml b/tests/configs_export_model/differential_items.yml index 67fe77227..ec9b97fe9 100644 --- a/tests/configs_export_model/differential_items.yml +++ b/tests/configs_export_model/differential_items.yml @@ -337,7 +337,7 @@ differential_expected: credential: default_environment: description: ansible-examples - local_path: _19__test_inventory_source_project + local_path: _20__test_inventory_source_project name: Test Inventory source project natural_key: name: Test Inventory source project @@ -377,7 +377,7 @@ differential_expected: type: credential default_environment: description: ansible-examples - local_path: _20__test_inventory_source_project_with_credential + local_path: _21__test_inventory_source_project_with_credential name: Test Inventory source project with credential natural_key: name: Test Inventory source project with credential diff --git a/tests/configure_controller.yml b/tests/configure_controller.yml index 281b48fd8..3f3f5c6b9 100644 --- a/tests/configure_controller.yml +++ b/tests/configure_controller.yml @@ -108,7 +108,6 @@ controller_bulk_hosts: "{{ temp_controller_bulk_hosts }}" when: - controller_bulk_launch_jobs is defined - - awx_version == "21.14.0" or awx_version == "devel" - name: Launch Controller Jobs ansible.builtin.include_role: @@ -150,7 +149,6 @@ wait: false when: - controller_bulk_launch_jobs is defined - - awx_version == "21.14.0" or awx_version == "22.0.0" or awx_version == "22.1.0" or awx_version == "devel" - name: Launch Controller workflows ansible.builtin.include_role: diff --git a/tests/configure_controller_export_model.yml b/tests/configure_controller_export_model.yml index 0c3c22d34..5b9486c0b 100644 --- a/tests/configure_controller_export_model.yml +++ b/tests/configure_controller_export_model.yml @@ -113,6 +113,4 @@ ansible.builtin.assert: that: - differential_expected == export_results.difference - when: - - awx_version == "devel" # It works on earlier versions, the issue is new fields fail in the differential. ...