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


No comments:

Post a Comment