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

Create Ansible groups based on arbitrary host facts. #55571

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
2 participants
@utoddl
Copy link

commented Apr 20, 2019

This only affects the contributed foreman inventory script.
Create Ansible groups based on arbitrary host facts.
Generate parent groups for created Ansible groups.

SUMMARY

This allows the easy creation of Ansible groups from indicated foreman host facts.
It also allows the creation of parent groups for all Ansible hostgroups generated from foreman.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

This only affects the foreman.py contributed inventory script.

ADDITIONAL INFORMATION

This change adds a couple of parameters to the foreman.ini file which configures the operation of the foreman.py inventory script. Specifically:
want_generated_parents: when True, creates parent groups for all created host groups. Default: False
group_facts: a list of host facts on which to create Ansible host groups. Defaults to an empty list.

For example, given these settings in the foreman.ini file:

[ansible]
want_generated_parents: True
group_facts: ["bios_vendor"]

The group_facts parameter would create host groups (in our case, for example) of

  "foreman_factgroup_bios_vendor": {
    "children": [
      "foreman_factgroup_bios_vendor_phoenixtechnologiesltd", 
      "foreman_factgroup_bios_vendor_ibm", 
      "foreman_factgroup_bios_vendor_hpe", 
      "foreman_factgroup_bios_vendor_hp"
    ]
  }, 

The want_generated_parents would generate parent groups for all created "foreman_*" groups, which can be very handy. In our case for example without want_generated_parents we get these host groups:

foreman_hostgroup_idman_krb_ones
foreman_hostgroup_idman_krb_zeros
foreman_hostgroup_idman_ng
foreman_hostgroup_idman_prod

but with want_generated_parents set to True, we also get these parent groups:

foreman_hostgroup_idman_krb
foreman_hostgroup_idman
Create Ansible groups based on arbitrary host facts.
Generate parent groups for created Ansible groups

@ansibot ansibot added the stale_ci label May 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.