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

support for ad-hoc groups created by the group_by module #201

Open
divansantana opened this issue Jul 30, 2019 · 3 comments
Open

support for ad-hoc groups created by the group_by module #201

divansantana opened this issue Jul 30, 2019 · 3 comments

Comments

@divansantana
Copy link

Thanks for this great software.

We use group_by ansible module to create ad-hoc groups based on our custom facts. This creates ad-hoc groups like env_dev env_prod , os_el6 etc.

Is there is a way to get these groups to be detected in ansible-cmdb?

@fboender
Copy link
Owner

Does the output of the following command include your ad-hoc groups?

ansible-inventory --list

If so, I'm thinking about rewriting the custom inventory parsing in ansible-cmdb to use the output of that command.

@divansantana
Copy link
Author

Various local custom facts and other nice vars are in the output of that command.

Here some of my custom facts in the output:

"ansible_local": {
"custom": {
"country": "za",
"datacenter": "b1",
"dmz": "untrusted"
}

So we have a task something like this in our code:

- name: FACTS | Classify hosts depending on their OS distribution and version
  group_by:
    key: os_{{ ansible_facts['distribution'] }}{{ ansible_facts['distribution_major_version'] }}
  tags: facts

- name: FACTS | Classify hosts depending on their country
  group_by:
    key: country_{{ ansible_facts['ansible_local']['custom']['country'] }}
  tags: facts

This would create an ad-hoc group like os_CentOS7 or country_za
during the playbook run.

It seems this data is not in the ansible-inventory output.

@fboender
Copy link
Owner

fboender commented Sep 5, 2021

There's an open PR (#215) that replaces the custom fact parser with ansible's default parser. I'm hoping this feature will be supported out of the box when I merge that PR.

I'll keep this issue open for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants