Ad-hoc Commands against Remote Hosts
Connect to remote Linux and Windows hosts using Ad-hoc commands.
We'll cover the following
Running ad-hoc commands on the localhost and containers is straightforward. It gets a little more involved, however, when you target remote hosts.
Ansible relies on an inventory to match a pattern against. The pattern localhost
creates an implicit inventory when you do not mention an inventory.
When you target remote hosts, you need to specify an inventory source. You pass an inventory to the ansible command with the -i
option. One method for defining an inventory is to create a host_list
.
You can create a host_list bypassing DNS names or IP addresses to the -i
option. A comma separates each DNS name or IP address. By default, Ansible attempts to parse the input of the -i
option as an inventory file. To bypass that, place a comma ,
at the end of the host_list
.
Get hands-on with 1400+ tech skills courses.