From Playbook to Production: Projects, Templates, Jobs, and Workflows in Practice
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
nebulahost 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
shellmodule, 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:
| Level | Label | What you actually get |
|---|---|---|
| 0 | Normal | Task results only, no module internals |
| 1 | Verbose (-v) | Module return values and basic task data |
| 2 | More Verbose (-vv) | Adds task input, file paths Ansible loaded, play recap details |
| 3 | Debug (-vvv) | Adds connection details: SSH commands, exec calls, sudo invocations |
| 4 | Connection Debug (-vvvv) | Adds full connection plugin debug output, including auth negotiation |
| 5 | WinRM 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
Limitpattern to target specific hosts in the inventory. Leaving the field blank or usingallor*will target all hosts in the inventory, but you can also use a pattern to focus on specific ones. For instance, settingLimittonebulawill target thenebulahost from the inventory.Click on Next
AWX in Action
Ansible Orchestration at ScaleEnroll now to unlock all content and receive all future updates for free.
