Configure interfaces with Ansible

 Today we will be configuring network devices from Ansible using ios_config module.


Ansible playbook to create loopback interfaces and add description
---
 - name: Define Parameters
  hosts: XE
  gather_facts: no
  connection: network_cli
  tasks:
    - name: Create loopback interfaces
      ios_config:
        lines:
          - description loopback interface by prashant
        parents: "{{ item }}"
      with_items:
          - interface loopback 25
          - interface loopback 30
          - interface loopback 35




[prashant@Prashant-VM01 ~]$ ansible-playbook play05.yml -i /home/prashant/inventory -u developer -k
SSH password:
 PLAY [Define Parameters] ****************************************************************************************************************
 TASK [Create loopback interfaces] *******************************************************************************************************
changed: [ios-xe-mgmt-latest.cisco.com] => (item=interface loopback 25)
changed: [ios-xe-mgmt-latest.cisco.com] => (item=interface loopback 30)
changed: [ios-xe-mgmt-latest.cisco.com] => (item=interface loopback 35)
changed: [ios-xe-mgmt.cisco.com] => (item=interface loopback 25)
changed: [ios-xe-mgmt.cisco.com] => (item=interface loopback 30)
changed: [ios-xe-mgmt.cisco.com] => (item=interface loopback 35)
 PLAY RECAP ******************************************************************************************************************************
ios-xe-mgmt-latest.cisco.com : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ios-xe-mgmt.cisco.com      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


Comments

Popular posts from this blog

Filtering Routes in BGP using Route-maps and Prefix-list

Export or Backup Azure Virtual Networks or Subnet information into CSV using PowerShell

Ansible Playbook for Network OS Upgrade with pre and post checks

Ansible-Playbook to display output of multiple show commands (using stdout_lines with Loop)

Ansible-playbook for backing up running config of Cisco IOS

Cisco ASA Active/Active Failover Configuration

VMware NSX Traffic Flow — East-West & North-South

Export or Backup Azure Route Table into CSV using PowerShell

Export or Backup Azure Network Security Groups into CSV using PowerShell

Anyconnect SSL-Client VPN with Self-signed Certificate on Cisco ASA