Closed LuPo closed 6 years ago
With this PR I propose not only to add hosts to a generic group when no group is selected, but as well those which are not in a chosen group. Below is the case with hosts grouped by rack_name
.
{
"_meta": {
"hostvars": {
"10002": {
"rack_name": "4200001",
"MAC": "bb:00:bb:00:00:bb"
},
"10003": {
"rack_name": "4200001",
"MAC": "cc:00:cc:00:00:cc"
},
"10005": {
"rack_name": "4200003",
"MAC": "dd:00:dd:00:00:dd"
},
"10010": {
"MAC": "ee:00:ee:00:ee:ee"
},
"10011": {
"MAC": "aa:bb:aa:bb:00:00"
},
"10012": {
"MAC": "00:00:00:00:00:00"
},
"10013": {
"rack_name": "4200003",
"MAC": "be:be:be:be:be:be"
}
}
},
"4200001": [
"10002",
"10003"
],
"4200003": [
"10005",
"10013"
],
"ungrouped": [
"10010",
"10011",
"10012"
]
}
Previously those hosts has not been grouped if not only in _meta
. This were leading to not being able to list all hosts like in this example:
ansible all -i netbox.py --list-hosts
hosts (4):
10005
10013
10002
10003
ansible ungrouped -i netbox.py --list-hosts
[WARNING]: Could not match supplied host pattern, ignoring: ungrouped
[WARNING]: No hosts matched, nothing to do
hosts (0):
With this PR the results are shown as follows:
ansible all -i netbox.py --list-hosts
hosts (7):
10010
10011
10012
10002
10003
10005
10013
ansible ungrouped -i netbox.py --list-hosts
hosts (3):
10010
10011
10012
Should had I submit a PR for it separately?
Thanks a lot @LuPo for your effort :+1:
group called "ungrouped" is indeed a default group implicit in an Ansible inventory.
With this pull request I propose to