Featured image

Table of Contents Link to heading

Scheduled Playbook Execution with AWX Link to heading

Once AWX is deployed and integrated with your Git repository, the typical onboarding sequence is straightforward: define an inventory, link your playbook source, then wire it to a schedule. The real value of AWX over raw Ansible CLI is the audit trail and scheduling engine โ€” every job run is logged with its output, timing, and exit status, giving you the operational visibility that cron-based automation lacks.

  1. Create an inventory:
    • Navigate to Inventories โ†’ Add New Inventory โ†’ Define Hosts.
  2. Import playbooks:
    • Connect AWX to a Git repository or upload playbooks manually.
  3. Schedule playbook execution:
    • Navigate to Templates โ†’ Add Playbook Template โ†’ Configure execution settings.
    • Enable scheduled jobs for recurring automation.
Tip
Store your inventory as a dynamic inventory script or integrate with a CMDB rather than maintaining a static INI file. As your device fleet grows, static inventories become a liability โ€” stale entries cause failed job runs that are difficult to distinguish from real device failures.

Automating Network Backups via AWX Scheduler Link to heading

Manual configuration backups are unreliable โ€” they depend on someone remembering to run them, often happen infrequently, and are rarely validated. Scheduling backups through AWX eliminates this dependency: configs are captured on a fixed cadence, versioned via the destination path, and failures are visible on the AWX dashboard immediately.

Scheduled Playbook for Network Configuration Backup Link to heading

- name: Backup Network Configuration
  hosts: routers
  tasks:
    - name: Retrieve Running Config
      cisco.ios.ios_command:
        commands:
          - show running-config
      register: running_config

    - name: Store Config in Backup Directory
      copy:
        content: "{{ running_config.stdout_lines }}"
        dest: "/backups/{{ inventory_hostname }}-config.txt"

Setting Up the Playbook in AWX Link to heading

  1. Upload this playbook to AWX’s Git-integrated repository.
  2. Create an execution template for backups.
  3. Set a schedule (e.g., every Sunday at midnight).
  4. AWX will automatically execute the backup without manual intervention.
Note
Consider appending a timestamp to the backup filename ({{ inventory_hostname }}-config-{{ ansible_date_time.date }}.txt) to retain historical snapshots rather than overwriting. Combine this with a retention policy to avoid filling the backup volume.

Event-Driven Remediation with Ansible and AWX Link to heading

Reactive automation โ€” where a monitoring event directly triggers a remediation playbook โ€” closes the gap between detection and response. Rather than alerting an engineer who then SSHs into a device to run diagnostics manually, the diagnostics run automatically, and results are logged before anyone looks at the alert.

Automatic Diagnostics on Ping Failure Link to heading

This playbook pings all routers, and if a failure is detected, Ansible automatically collects troubleshooting data.

- name: Automated Network Troubleshooting
  hosts: routers
  tasks:
    - name: Ping Network Devices
      ping:
      register: ping_status

    - name: Run Diagnostics if Ping Fails
      block:
        - name: Gather Routing Table
          cisco.ios.ios_command:
            commands:
              - show ip route
          register: routing_table

        - name: Check Interface Status
          cisco.ios.ios_command:
            commands:
              - show ip interface brief
          register: interfaces

        - name: Log Output
          copy:
            content:
              - "Routing Table: {{ routing_table.stdout_lines }}"
              - "Interfaces: {{ interfaces.stdout_lines }}"
            dest: "/logs/troubleshooting_{{ inventory_hostname }}.log"
      when: ping_status.failed

Integrating Event-Driven Automation with AWX Link to heading

  1. Use AWX’s API to trigger troubleshooting playbooks.
  2. Set up Webhooks with monitoring tools (e.g., Zabbix, Prometheus).
  3. Whenever a device goes offline, AWX will automatically trigger the diagnostics playbook.
Tip
Pass the affected device’s hostname as an extra variable when triggering the AWX job template via API (--extra-vars "target_host=router1"). This avoids running diagnostics against the entire inventory when only one device is impacted, saving time and reducing noise in the log output.

Automatic Firewall Response to Unauthorised Access Link to heading

When a monitoring or SIEM system flags suspicious activity โ€” repeated failed authentication, unexpected inbound connections โ€” the fastest response is a playbook that isolates the source before a human reviews it. This example blocks the flagged IPs at the firewall layer automatically.

- name: Block Unauthorised IP Addresses
  hosts: firewalls
  tasks:
    - name: Retrieve Active Connections
      cisco.ios.ios_command:
        commands:
          - show conn
      register: active_connections

    - name: Block Suspicious IPs
      cisco.ios.ios_acl:
        name: BLOCK_INTRUSION
        entries:
          - sequence: 10
            action: deny
            protocol: tcp
            src: "{{ active_connections.stdout_lines | regex_findall('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') }}"
            dest: any
            dport: 22
Warning
The regex in this example extracts all IPs from the show conn output without filtering. In production, apply an exclusion list of trusted IP ranges before blocking โ€” an overly broad ACL can inadvertently cut off legitimate management traffic, including your own session.

Triggering This Playbook Automatically Using AWX Link to heading

  1. Set up AWX Webhooks
    • Enable AWX Webhooks to listen for security alerts (e.g., failed SSH login attempts).
    • If an intrusion is detected, AWX automatically runs the firewall blocking playbook.
    • Integrate AWX with security tools (Splunk, ELK Stack) for threat monitoring.
  2. Integrate with SIEM Tools
    • Connect AWX to Splunk, ELK Stack, or Security Event Monitors.
    • Automate security incident reports when attacks happen.

Run the playbook manually:

ansible-playbook block_intrusion.yml -i inventory.ini

Configuring AWX Job Templates for Auto-Triggered Diagnostics Link to heading

Configure AWX Job Templates for automatic log collection when connectivity issues arise. A typical workflow: monitoring tool detects a threshold breach โ†’ sends a webhook to AWX โ†’ AWX launches the appropriate playbook โ†’ results are stored and a notification is sent to the operations channel.

Monitoring Network Health with AWX Dashboards Link to heading

AWX’s built-in dashboard provides a centralised view of job execution history, success/failure rates, and recent activity โ€” but it’s most useful when paired with external monitoring tools that provide device-level telemetry. The combination of AWX for automation state and a dedicated monitoring stack (Zabbix, Prometheus/Grafana) for device health gives full operational coverage.

Setting Up AWX for Network Monitoring Link to heading

  1. Enable Job Status Tracking

    • AWX logs playbook execution results in the dashboard.
    • Monitor which automation tasks succeed or fail.
  2. Connect to Monitoring Tools

    • Use AWX’s API to integrate Zabbix, Prometheus, or Grafana.
    • Create alerts for failed playbook executions.
  3. Automate Remediation Playbooks

    • If a monitoring tool detects device failures, AWX triggers Ansible playbooks automatically.
    • Example: If a router fails, AWX runs a troubleshooting playbook instantly.

Detecting Configuration Drift with AWX Link to heading

Configuration drift โ€” where the running config on a device diverges from the known-good baseline โ€” is one of the most common sources of hard-to-diagnose issues in production networks. This playbook detects drift by comparing the live config against the last backup, logging any differences for review.

- name: Monitor Network Configurations
  hosts: routers
  tasks:
    - name: Retrieve Running Config
      cisco.ios.ios_command:
        commands:
          - show running-config
      register: current_config

    - name: Compare with Previous Backup
      command: diff /backups/{{ inventory_hostname }}-config.txt /tmp/current_config.txt
      register: diff_output
      ignore_errors: yes

    - name: Log Unauthorised Changes
      copy:
        content: "{{ diff_output.stdout_lines }}"
        dest: "/logs/config_change_{{ inventory_hostname }}.log"
      when: diff_output.stdout_lines | length > 0

Automating This Workflow in AWX Link to heading

  1. Upload the playbook into AWX
  2. Schedule execution every 6 hours
  3. Enable alerts for unauthorised changes
  4. Use AWX’s REST API to notify security teams
Tip
Integrate the diff output with a ticketing system (e.g., ServiceNow, Jira) via the AWX REST API webhook. This creates an automatic change record when drift is detected, giving operations teams a traceable audit trail without manual ticket creation.