Skip to content

Instantly share code, notes, and snippets.

@blocke
Created October 3, 2013 16:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blocke/6812723 to your computer and use it in GitHub Desktop.
Save blocke/6812723 to your computer and use it in GitHub Desktop.
Mockup of what a using a Cisco module for Ansible might look like:
---
- hosts: myciscoswitch
connection: cisco
user: adminuser
tasks:
- name: raw template (not idempotent)
cisco: action=raw src=foo.j2
- name: raw single line (not idempotent)
cisco: action=raw line="vtp version 2"
- name: global options that should be present (idempotentish)
cisco: action=config type=global line={{ item }} state=present
with_items:
- clock summer-time EDT recurring 2 Sun Mar 2:00 1 Sun Nov 2:00
- clock timezone Eastern -5
- errdisable recovery cause link-flap
- no logging console
- ip default-gateway 192.168.1.1
- name: global options that should not be present (idempotentish)
cisco: action=config type=global line={{ item }} state=absent
with_items:
- errdisable recovery cause bpduguard
- snmp-server enable traps envmon fan shutdown supply temperature status
- name: interface settings (with ranges supported)
cisco: action=config type=interface interface="Gi1/0/3-9" line={{ item }} state=present
with_items:
- switchport access vlan 20
- switchport mode access
- storm-control broadcast level 10.00
- storm-control multicast level 60.00
- storm-control unicast level 80.00
- spanning-tree portfast
- name: interface settings with absent
cisco: action=config type=interface interface="Gi1/0/3-9" line={{ item }} state=absent
with_items:
- ip dhcp snooping trust
- switchport trunk native vlan 1
- name: vty line settings
cisco: action=config type=line line="vty 0 4" line={{ item }} state=present
with_items:
- session-timeout 900
- transport input ssh
- name: write mem and reload
cisco: action=raw line="write mem"
cisco: action=reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment