To execute an ad-hoc command on any host, we need to do the following:
- We need to go to the Inventories tab from the top navigation bar and select the cookbook inventory.
- Once the inventory section opens up, we need to go to the Hosts tab and select the host on which we want to execute the command.
- After selecting the host, click on the RUN COMMANDS button.
- A form for executing commands will open up. We can choose the module to execute the command. For this example, we will select the shell module from the module dropdown and provide the command in the ARGUMENTS field.
- We have to provide a credential so that Ansible can execute the command. We can click on the lens icon in the machine credential field and select the credential ...