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

An inventory source is not ever assigned to an organization #563

Conversation

ivarmu
Copy link
Contributor

@ivarmu ivarmu commented Apr 4, 2023

What does this PR do?

When exporting an inventory source, if it has not associated organization, the filetree_create role will fail as no organization field is found. This is fixing that error and setting a ToDo organization name instead.

How should this be tested?

Automatic tests.

Is there a relevant Issue open for this?

N/A

Other Relevant info, PRs, etc

N/A

@ivarmu ivarmu added the bug Something isn't working label Apr 4, 2023
@djdanielsson
Copy link
Collaborator

I am not sure I like this...

@ivarmu
Copy link
Contributor Author

ivarmu commented Apr 4, 2023

I am not sure I like this...

Have in mind that the filetree_create is intended to export the current objects from an already configured instance of Tower/Controller, so it's out of our control the original state for that objects... even if the inventory_source has been defined as code and deployed, this field is non mandatory (see https://github.com/redhat-cop/controller_configuration/blob/9478b34cf212666dd9c5a324be97387da7ee5be5/roles/inventory_sources/tasks/main.yml#L8) so... maybe it should be better to drop the entire line instead of setting the ToDo organization?

@sean-m-sullivan
Copy link
Collaborator

sean-m-sullivan commented Apr 4, 2023

The ONLY use of organization in the inventory source is to lookup the parent inventory, So if the ORG does not exist, it should not matter, its if the parent inventory exists is the key question.

The actual use case if for cases where the user has access to multiple orgs where they have identical inventory names.

I am not sure what scenario this is trying to fix, where filetree create, creates an inventory source with no org, which should be fixed in create, or user error where they added it manuallly?

@ivarmu
Copy link
Contributor Author

ivarmu commented Apr 4, 2023

This is trying to fix the error thrown by the filetree_create when is exporting an inventory_source that is not assigned to any organization. That scenario is currently breaking the execution and it shouldn't, as it is a real and feasible case.

@adonisgarciac
Copy link
Contributor

I'm not sure in what cases it's possible to have an inventory_source without organization. I mean, organization is mandatory for inventories and inventory is mandatory for inventory_sources. Then, inventory_source should always have inventory_source.summary_fields.organization.name.

I don't understand why awx/controller module accepts organization for inventory_source https://docs.ansible.com/ansible/latest/collections/awx/awx/inventory_source_module.html#parameter-organization when if you set an organization different than inventory's organization, it will fail.

On the other hand, controller_object_diff is trying to compare organization but it could fail because organization is not mandatory for inventory_source:

https://github.com/redhat-cop/controller_configuration/blob/devel/plugins/lookup/controller_object_diff.py#L151-L153
https://github.com/redhat-cop/controller_configuration/blob/devel/plugins/lookup/controller_object_diff.py#L183-L186

@sean-m-sullivan
Copy link
Collaborator

Until we move to export, the summary fields is the only way to look at this, it should not be possible to have an inventory without an org, so this should always work.

@sean-m-sullivan sean-m-sullivan merged commit 04a2b58 into redhat-cop:devel Apr 7, 2023
sean-m-sullivan pushed a commit to sean-m-sullivan/aap_configuration that referenced this pull request Apr 8, 2023
…op#563)

* an inventory source is not ever assigned to an organization

* if no organization, no output for organization field
sean-m-sullivan added a commit that referenced this pull request Apr 10, 2023
* An inventory source is not ever assigned to an organization (#563)

* an inventory source is not ever assigned to an organization

* if no organization, no output for organization field

* linting

* update workflow

---------

Co-authored-by: Ivan Aragonés Muniesa <[email protected]>
sean-m-sullivan added a commit that referenced this pull request Apr 12, 2023
* An inventory source is not ever assigned to an organization (#563)

* an inventory source is not ever assigned to an organization

* if no organization, no output for organization field

* linting

* update workflow

* update enforced defaults

---------

Co-authored-by: Ivan Aragonés Muniesa <[email protected]>
@ivarmu ivarmu deleted the fix_inventory_sources_filetree_create branch March 27, 2024 07:07
przemkalit pushed a commit to przemkalit/aap_configuration that referenced this pull request Nov 22, 2024
…op#563)

* an inventory source is not ever assigned to an organization

* if no organization, no output for organization field
przemkalit pushed a commit to przemkalit/aap_configuration that referenced this pull request Nov 22, 2024
* An inventory source is not ever assigned to an organization (redhat-cop#563)

* an inventory source is not ever assigned to an organization

* if no organization, no output for organization field

* linting

* update workflow

---------

Co-authored-by: Ivan Aragonés Muniesa <[email protected]>
przemkalit pushed a commit to przemkalit/aap_configuration that referenced this pull request Nov 22, 2024
* An inventory source is not ever assigned to an organization (redhat-cop#563)

* an inventory source is not ever assigned to an organization

* if no organization, no output for organization field

* linting

* update workflow

---------

Co-authored-by: Ivan Aragonés Muniesa <[email protected]>
przemkalit pushed a commit to przemkalit/aap_configuration that referenced this pull request Nov 22, 2024
* An inventory source is not ever assigned to an organization (redhat-cop#563)

* an inventory source is not ever assigned to an organization

* if no organization, no output for organization field

* linting

* update workflow

* update enforced defaults

---------

Co-authored-by: Ivan Aragonés Muniesa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants