ACL’s with Ansible

Here’s a playbook that shows creating an ACL, adding to an ACL and deleting an ACL in a Cisco device.

---
- name: Cisco Module Test
  hosts: cisco_devices

  tasks:

    - name: Create Access List 'test'
      ios_config:
        lines:
          - 10 permit ip host 1.1.1.1 any log
          - 20 permit ip host 2.2.2.2 any log
          - 30 permit ip host 3.3.3.3 any log
          - 40 permit ip host 4.4.4.4 any log
          - 50 permit ip host 5.5.5.5 any log
        parents: ip access-list extended test
        before: no ip access-list extended test
        match: exact

    - name: Add an ACE to the 'test' ACL
      ios_config:
        lines:
          - permit ip host 6.6.6.6 any log
        parents: ip access-list extended test
        match: exact

    - name: Remove an Access-List named 'test'
      ios_config:
        lines:
          - no ip access-list extended test

 

Leave a Reply