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

inventory_sources built using the api plugin in object_diff do not include the source key #773

Closed
w4hf opened this issue Feb 23, 2024 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists filetree/object_diff

Comments

@w4hf
Copy link
Contributor

w4hf commented Feb 23, 2024

Summary

When trying to remove inventory_sources not declared in Conf as code using the object_diff role, the role fails in the task [ infra.configuration.inventory_sources : Managing Inventory Sources ] with the following error :

fatal: [localhost]: FAILED! => {"msg": "The conditional check '__controller_source_item.source != \"constructed\"' failed. 
The error was: error while evaluating conditional (__controller_source_item.source != \"constructed\"): 'dict object' has no attribute 'source'.
'dict object' has no attribute 'source'\n\nThe error appears to be in 
'/home/gitlab-runner/.ansible/collections/ansible_collections/infra/configuration/roles/inventory_sources/tasks/main.yml': 
line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\n
The offending line appears to be:\n\n---\n- name: \"Managing Inventory Sources\"\n ^ here\n"}

Because the inventory_sources list read from the Controller using the API plugin do not create a source key for each element in the list. Below an example of the controller_inventory_sources list built using the object_diff role. We can see that there is no key source :

TASK [infra.configuration.object_diff : Set inventory_sources' list to be configured] ***
task path:
/home/gitlab-runner/.ansible/collections/ansible_collections/infra/configuration/roles/object_diff/tasks/inventory_sources.yml:27
ok: [localhost] => 
{"ansible_facts": {"controller_inventory_sources": [{"inventory": "TEST INVENTORY", "name": "TEST Inventory Source", "organization": "Test", "state": "absent"}]}, "changed": false}

Issue Type

  • Bug Report

Ansible, Collection, Controller details

ansible version : 2.15.0

used collections :
ansible.controller 4.5.1
infra.controller_configuration 2.6.0

Controller version 4.5.1

  • ansible installation method: OS package

OS / ENVIRONMENT

RHEL 8.6

Desired Behavior

Each element of the list controller_inventory_sources built using the object_diff role automatically from the Controller should have the key source

Actual Behavior

The elements of the list controller_inventory_sources do not contains the key source which cause the role to fail in the task [ infra.configuration.inventory_sources : Managing Inventory Sources ]

STEPS TO REPRODUCE

Manually create an inventory_source in the Controller web interface that do is not declared in the configuration as code. Then call the object diff role to remove inventory_sources not in the configuration as code as follow :

    - role: infra.controller_configuration.object_diff
      vars:
        controller_configuration_object_diff_tasks:
          - {name: inventory_sources, var: controller_inventory_sources, tags: inventory_sources}
@w4hf w4hf added bug Something isn't working new New issue, this should be removed once reviewed labels Feb 23, 2024
@djdanielsson djdanielsson added filetree/object_diff and removed new New issue, this should be removed once reviewed labels Feb 29, 2024
@mmaaz1
Copy link

mmaaz1 commented Mar 4, 2024

Ran into the same issue. Had to revert to version 2.5.2 as a workaround. Looks like the bug was introduced by this change?

#720

@ivarmu ivarmu added the duplicate This issue or pull request already exists label Mar 18, 2024
@ivarmu
Copy link
Contributor

ivarmu commented Mar 18, 2024

This is a duplicate of #783 and is solved at #755. As they are both closed, I'm closing this one, too.

@ivarmu ivarmu closed this as completed Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists filetree/object_diff
Projects
None yet
Development

No branches or pull requests

4 participants