Feedback

Chat Icon

AWX in Action

Ansible Orchestration at Scale

From Playbook to Production: Projects, Templates, Jobs, and Workflows in Practice
52%

Ad-Hoc Commands: One-Liners Without a Playbook

To start, we'll execute an ad-hoc command on the nebula host.

Ad-hoc commands are one-off Ansible tasks you run directly against an inventory without writing a playbook, using a single module call.

To test this, navigate to the Inventories menu and select the inventory you wish to target.

For this demonstration, we'll use the NebulaInventory inventory. These are the steps to follow:

  • Click on this inventory, then go to the Hosts tab.
  • Locate the nebula host in the list, select it, and click on the Run Command button.
  • First, choose the module you want to use. For this example, we'll use the shell module, which runs commands on the host.

You can specify arguments for the module. For the shell module, this means the command you want to execute. In this case, we'll run echo "Hello, World!" > /tmp/hello.txt.

  • Select the verbosity level. This determines how much information is displayed in the output. Here are the verbosity levels available:
LevelLabelWhat you actually get
0NormalTask results only, no module internals
1Verbose (-v)Module return values and basic task data
2More Verbose (-vv)Adds task input, file paths Ansible loaded, play recap details
3Debug (-vvv)Adds connection details: SSH commands, exec calls, sudo invocations
4Connection Debug (-vvvv)Adds full connection plugin debug output, including auth negotiation
5WinRM Debug (-vvvvv)Adds WinRM protocol traces; only meaningful for Windows targets

Stay at 0 or 1 for normal runs, jump to 3 when debugging failed tasks, and only go to 4 or 5 when you suspect the transport itself (SSH handshake, WinRM auth) is the problem. Higher levels generate large amounts of output and can leak sensitive data into job logs.

  • You can also use the Limit pattern to target specific hosts in the inventory. Leaving the field blank or using all or * will target all hosts in the inventory, but you can also use a pattern to focus on specific ones. For instance, setting Limit to nebula will target the nebula host from the inventory.

  • Click on Next

AWX in Action

Ansible Orchestration at Scale

Enroll now to unlock all content and receive all future updates for free.