Back to Ansible Reference

$ ansible-doc -t module cisco.sccfm.execute_asa_cli

> MODULE cisco.sccfm.execute_asa_cli (sccfm-ansible/plugins/modules/execute_asa_cli.py)

  Execute CLI commands on one or more ASA devices managed by SCC
  Firewall Manager.
  Devices can be selected by a Lucene query or by specifying a list of
  UIDs.
  The query uses the same syntax as the Get Devices API.
  See
  https://developer.cisco.com/docs/cisco-security-cloud-control-firewall-manager/get-devices/
  for query documentation.

OPTIONS (= indicates it is required):

- api_token  API token for SCCFM.
        set_via:
          env:
          - name: SCCFM_API_TOKEN
        default: null
        no_log: true
        type: str

- command  Single ASA CLI command to execute.
            Mutually exclusive with `commands'. Use `commands' to run
            more than one command.
        default: null
        type: str

- commands  List of ASA CLI commands to execute.
             Commands are executed in order.
             Mutually exclusive with `command'.
        default: null
        elements: str
        type: list

- limit   Maximum number of devices to return when using `query'.
           Ignored when using `uids'.
        default: 50
        type: int

- offset  Pagination offset when using `query'.
           Ignored when using `uids'.
        default: 0
        type: int

- query   Lucene query to filter ASA devices.
           Mutually exclusive with `uids'.
           The query is automatically combined with `deviceType:ASA'.
        default: null
        type: str

- region  SCCFM region (int, us, eu, apj, au, uae, in, or ci).
        set_via:
          env:
          - name: SCCFM_REGION
        default: null
        type: str

- uids    List of device UIDs to execute commands on.
           Mutually exclusive with `query'.
        default: null
        elements: str
        type: list

AUTHOR: Cisco SCCFM Team

EXAMPLES:
# Example 1: Execute commands on devices matching a query
- name: Show version on all production ASAs
  cisco.sccfm.execute_asa_cli:
    query: "name:prod-* AND connectivityState:ONLINE"
    commands:
      - "show version"
      - "show running-config"
    region: "{{ sccfm_region }}"
    api_token: "{{ sccfm_api_token }}"
  register: cli_results

# Example 2: Execute commands on specific devices by UID
- name: Show interface on specific ASAs
  cisco.sccfm.execute_asa_cli:
    uids:
      - "12345678-1234-1234-1234-123456789abc"
      - "87654321-4321-4321-4321-cba987654321"
    commands:
      - "show interface"
  register: cli_results

# Example 3: Using module_defaults (recommended)
- name: Execute CLI commands on ASAs
  hosts: localhost
  gather_facts: false
  module_defaults:
    group/cisco.sccfm.all:
      region: "{{ sccfm_region }}"
      api_token: "{{ sccfm_api_token }}"
  tasks:
    - name: Show version on branch ASAs
      cisco.sccfm.execute_asa_cli:
        query: "name:branch-* AND connectivityState:ONLINE"
        command: "show version"

# Example 4: Use Ansible's lookup to read commands from a file (one command per line)
- name: Execute commands from file
  cisco.sccfm.execute_asa_cli:
    query: "name:prod-* AND connectivityState:ONLINE"
    commands: "{{ lookup('file', 'scripts/show_commands.txt').splitlines() }}"

RETURN VALUES:

- command  The CLI script that was executed. Multiple commands are
            joined with newlines.
        returned: success
        type: str

- commands  List of ASA CLI commands that were executed.
        elements: str
        returned: success
        type: list

- device_count  Number of target devices matched by the module.
        returned: success
        type: int

- results  List of CLI execution results per device.
        elements: dict
        returned: success
        type: list
        contains:

        - device_uid  The UID of the device.
          type: str

        - error_msg  Error message if execution failed on this device
                      (None if successful).
          type: str

        - execution_uid  The UID of the CLI execution.
          type: str

        - result  The CLI command output.
          type: str

        - script  The script that was executed.
          type: str

        - start_time  The time the CLI execution started (ISO 8601
                       format).
          type: str

        - uid  The UID of the CLI result.
          type: str