playbookFile=./showAnsibleGroups; cat << EOF > "$playbookFile" && chmod +x "$playbookFile" #!/usr/bin/env ansible-playbook - hosts: all gather_facts: no tasks: - name: show the groups the host(s) are in debug: msg: "{{group_names}}" EOF
TASK [show the groups the host(s) are in] *********************************************************************** ok: [myServer1] => { "msg": [ "RHEL", "RHEL8", "preprod" ] } PLAY RECAP ****************************************************************************************************** myServer1 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 myServer2 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
inventory filesdirectory
How can I check the actual list of hosts resulting from my inventory expression ?The easy solution would be to run
Is it even possible from a workstation that has no access to the managed hosts ?
all that has everybody).[groupSlaves] group name slave1 ansible_host=192.168.105.114 details slave2 ansible_host=192.168.105.80 [myGroup1] group name slave1 [myGroup2] group name slave2
all includes all slaves.ungrouped. The logic behind Ansible is that all slaves must belong to at least 2 groups : all and "an other one". If there is no such "other one", ungrouped will be that one.