Forrest logo
back to the ansible tool

ansible:tldr:fba27

ansible: List hosts belonging to a group.
$ ansible ${group} --list-hosts
try on your machine

The command ansible ${group} --list-hosts is an Ansible command used to display the list of hosts that are part of a specific group.

Here's a breakdown of the command:

  • ansible: Refers to the Ansible command-line tool used to execute various tasks on managed hosts.
  • ${group}: Denotes the group for which you want to display the list of hosts. ${group} should be replaced with the actual name of the group you are interested in.
  • --list-hosts: This is an Ansible option that specifies the action to be performed. In this case, it instructs Ansible to list the hosts belonging to the specified group.

When you run this command, Ansible will go through its inventory to find all the hosts that are part of the specified group and display their names on the screen. The inventory is usually defined in the /etc/ansible/hosts file or a custom inventory file specified using the -i option. This command helps to quickly view the hosts that are included in a particular Ansible inventory group.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ansible tool