Run Ansible Ad-Hoc Commands On Localhost

This blog post, will show you how to use and run Ansible ad-hoc commands on a local host manchine.

Ad-Hoc Commands

Running ad-hoc commands on localhost or any host in an inventory is used for quick tests and not operational procedures.

Running Ad-Hoc Commands on a localhost

the syntax to run an ad-hoc commands on a localhost is very shwon below.

ansible host -m [module] -a [options ]

In the following example, I will run an ad-hoc command that will use the shell module and run the export command to see all the variables.

ansible localhost -m shell -a export

For more Ansible post, please visit the category page.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.