Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid the hosts populated by a constructed inventory to be removed #747

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/issue_743.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Avoid the hosts populated by a constructed inventory to be removed
3 changes: 2 additions & 1 deletion roles/object_diff/tasks/hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
query_params={'organization': controller_organization_id.id,
'has_inventory_sources': 'false',
'not__total_hosts': '0',
'not__kind': 'smart'},
'not__kind': 'smart',
'not__kind': 'constructed'},
host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs,
return_all=true, max_objects=query_controller_api_max_objects)
}}"
Expand Down
12 changes: 12 additions & 0 deletions tests/configs/differential_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ differential_items:
- name: Test Inventory - Smart
organization: Default
state: absent
- name: hosts
with_present: false
differential_test_items:
- name: localhost
inventory: Demo Inventory
expected_test_result:
- name: "localhost"
inventory: "RHVM-01"
state: absent
- name: "localhost"
inventory: "localhost"
state: absent
- name: teams
with_present: false
differential_test_items:
Expand Down
2 changes: 1 addition & 1 deletion tests/configure_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
validate_certs: "{{ controller_validate_certs }}"
ignore_errors: true # noqa ignore-errors

- name: Get the organization ID
- name: "Get the organization ID"
ansible.builtin.set_fact:
controller_organization_id: "{{ lookup(controller_api_plugin, 'organizations', query_params={'name': 'Default'}, host=controller_hostname, username=controller_username, password=controller_password, verify_ssl=false) }}"

Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/differential.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: "Get the API list in the Default Organization of all {{ differential_item.name }}"
ansible.builtin.set_fact:
controller_api_results: "{{ query(controller_api_plugin, differential_item.name, query_params={'organization': controller_organization_id.id}, host=controller_hostname, username=controller_username, password=controller_password, verify_ssl=false) }}"
controller_api_results: "{{ query(controller_api_plugin, differential_item.name, query_params=({'organization': controller_organization_id.id}) if differential_item.name is not match('hosts') else {}, host=controller_hostname, username=controller_username, password=controller_password, verify_ssl=false) }}"

- name: "Find the difference between what is on the Controller versus curated list of {{ differential_item.name }}"
ansible.builtin.set_fact:
Expand Down
Loading