admin:ansible:snippets

Useful Ansible snippets

list all inventory groups alphabetically

ansible localhost -m debug -a 'var=groups.keys()|sort'

list all hosts in group

ansible $GROUP_NAME --list-hosts

list all groups a host is in

ansible $HOST_NAME_AS_IN_INVENTORY -m debug -a 'var=group_names'

Run this on FreeBSD which is not on PowerPC, or on Debian:

when: "(ansible_os_family == 'FreeBSD' and ansible_architecture != 'powerpc') or ansible_os_family == 'Debian'"
  • Last modified: 2023-04-01 19:37