ansible/ansible — pull request #4230 by bennojoy (2013-09-24 16:44:51+00:00)
Title: Cisco support in Ansible

## Configuring Cisco Devices with Ansible

This PR introduces a cisco transport plugin and a module which allows users/network_admins to configure
Cisco devices via Ansible, The implementation logic is quite straight forward, Network users/admins
can create template files for their usual network configurations and instruct the module to execute
those configurations in all or certain subset of thier network infrastructure.
The template file is parsed by jinja and any variable substituations are carried out. The module has been tested on
Cisco IOS as well as NX-OS.

The Cisco transport plugin supports telnet and ssh as means to communicating with the device, It also
supports enabling privilege mode transition(enable) on the target devices. Transport type can be set
at individual device level, so if a device uses telnet instead of ssh while making the entry for the device in inventory
the user can add a variable similar to the follwing " cisco_tranport=telnet", and plugin would use
telnet as the transport.

Following is an example where a Cisco routers interface is configured.

```
Inventory:
[ios]
router1 cisco_transport=telnet ansible_ssh_host=192.168.2.20

playbook:
- hosts: ios
user: ben
connection: cisco
vars:
interface_name: "f0/1"
ip_address: "10.0.0.3"
netmask: "255.255.255.0"
gather_facts: no
tasks:
- name: Cisco command
action: cisco src=interface.j2 enable=yes enable_pass="foobar" commit="startup-config"

Interface.j2 file:
conf t
int {{ interface_name }}
ip address {{ ip_address }} {{ netmask }}
exit
exit

Execution:

ansible-playbook -i hosts cisco.yml -k -vv
```

More information about the module is available via the module documentation.
Note: Currently the module is non idempotent, but i am contemplating to make it idempotent by gathering facts from network devices before the module is run and those facts can used to conditionally execute the task "when:".

Feedbacks and suggestion are welcome.