Last active
May 5, 2023 23:16
-
-
Save lilongen/ebc11f69ae2ba48971c77527d5c02fab to your computer and use it in GitHub Desktop.
How to run Ansible without specifying the inventory but the host directly?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Question: | |
. How to run Ansible without specifying the inventory but the host directly? | |
. Run a playbook or command with arbitrary host not in the inventory hosts list? | |
. run ansible with arbitrary host/ip without inventory? | |
Answer: | |
Surprisingly, the trick is to append a , | |
The host parameter preceding the , can be either a hostname or an IPv4/v6 address. | |
ansible all -i example.com, | |
ansible all -i 93.184.216.119, | |
ansible-playbook -i example.com, playbook.yml # Requires 'hosts: all' in the playbook |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can this
ansible all -i ip1,ip2-m shell -a "ifconfig"
. be executed on two machine?