ansible-task
Execute Ansible ad-hoc commands on inventory hosts, specifying module and arguments, with support for privilege escalation, check mode, and diff output.
Instructions
Run an ad-hoc Ansible task using the ansible CLI.
Args: host_pattern: Inventory host pattern to target (e.g., 'all' or 'web') module: Module name (e.g., 'ping', 'shell') args: Module arguments, either dict or string inventory: Inventory path or host list become: Use privilege escalation become_user: Target user when using become check: Check mode diff: Show diffs cwd: Working directory verbose: Verbosity level 1-4 connection: Connection type (e.g., 'local', 'ssh'). Defaults to 'local' when targeting localhost. Returns: A dict with keys: ok (bool), rc, stdout, stderr, command
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| env | No | ||
| args | No | ||
| diff | No | ||
| check | No | ||
| become | No | ||
| module | Yes | ||
| verbose | No | ||
| inventory | No | ||
| connection | No | ||
| become_user | No | ||
| host_pattern | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||