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

Foreman inventory does not sync empty groups #919

Closed
Akasurde opened this issue Aug 12, 2020 · 6 comments · Fixed by #931
Closed

Foreman inventory does not sync empty groups #919

Akasurde opened this issue Aug 12, 2020 · 6 comments · Fixed by #931

Comments

@Akasurde
Copy link

From @rht-jbittner on Mar 27, 2020 11:19

SUMMARY

Foreman dynamic inventory script does not sync empty host groups.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Foreman/Red Hat Satellite dynamic inventory

ANSIBLE VERSION
All
STEPS TO REPRODUCE

Create empty host group in Foreman/Red Hat Satellite and sync inventory. Groups without hosts are not synced.

EXPECTED RESULTS

All groups synced. Syncing empty host groups is important due to group inheritance. Like in Ansible you can have host group which contains multiple sub groups and define variables on parent group level. This is not possible with current state of the inventory script.

ACTUAL RESULTS

Only groups with host synced.

Problem with foreman inventory script is that it does not call Foreman hostgroup API and construct group and membership from hosts instead.

Copied from original issue: ansible/ansible#68508

@Akasurde
Copy link
Author

From @jctanner on Apr 14, 2020 11:24

!component =contrib/inventory/foreman.py

@evgeni
Copy link
Member

evgeni commented Aug 17, 2020

@Akasurde FWIW, contrib/inventory/foreman.py was not migrated here, only plugins/inventory/foreman.py (which is a different! inventory) was. It might have the same bugs, but just blindly assuming that feels wrong ;)

@evgeni
Copy link
Member

evgeni commented Aug 18, 2020

That said, it does look like it applies to our inventory too.

@ares @ezr-ondrej would one of you be able to look into this?

@ezr-ondrej
Copy link
Member

Sure, I'll try to take a look what is happening there

@ezr-ondrej
Copy link
Member

@evgeni I can see there is no sync for hostgroups in the sync script, should we add it there before host sync?

@evgeni
Copy link
Member

evgeni commented Aug 24, 2020

@ezr-ondrej I guess that'd be required, yeah. Not sure how it'd play with the search parameter though.

Can we get a list of hosts and then only sync all groups (and parents) that those hosts belong to?

ezr-ondrej added a commit to ezr-ondrej/foreman-ansible-modules that referenced this issue Aug 25, 2020
ezr-ondrej added a commit to ezr-ondrej/foreman-ansible-modules that referenced this issue Aug 25, 2020
ezr-ondrej added a commit to ezr-ondrej/foreman-ansible-modules that referenced this issue Sep 9, 2020
evgeni pushed a commit that referenced this issue Sep 9, 2020
pondrejk pushed a commit to pondrejk/foreman-ansible-modules that referenced this issue Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants