Skip to content

Instantly share code, notes, and snippets.

View privateip's full-sized avatar

Peter Sprygada privateip

View GitHub Profile
@privateip
privateip / gist:b11dff211cbda60a0e99
Last active March 11, 2016 17:16
simple change using --check
(ansible)[network]$ ansible-playbook change_hostname.yaml --check
PLAY [veos01] ******************************************************************
TASK [eos_config] **************************************************************
changed: [veos01]
TASK [debug] *******************************************************************
ok: [veos01] => {
"result": {
#
# (c) 2016 Peter Sprygada <psprygada@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
(ansible)[ansible-ios]$ ansible -m ios_facts -a "host=ios01 username=cisco password=cisco authorize=true gather_subset=all" ios01
ios01 | SUCCESS => {
"ansible_facts": {
"ansible_net_all_ipv4_addresses": [
"172.26.4.30"
],
"ansible_net_all_ipv6_addresses": [],
"ansible_net_config": "Building configuration...\n\nCurrent configuration : 3205 bytes\n!\n! Last configuration change at 20:15:33 UTC Tue May 24 2016 by ********\n!\nversion 15.6\nservice timestamps debug datetime msec\nservice timestamps log datetime msec\nno service password-encryption\n!\nhostname veos01\n!\nboot-start-marker\nboot-end-marker\n!\n!\nvrf definition Mgmt-intf\n !\n address-family ipv4\n exit-address-family\n !\n address-family ipv6\n exit-address-family\n!\nno logging buffered\nlogging console informational\nenable password ********\n!\nno aaa new-model\nethernet lmi ce\n!\n!\n!\nmmi polling-interval 60\nno mmi auto-configure\nno mmi pvc\nmmi snmp-timeout 180\n!\n!\n!\n!\n!\n!\n!\n!\n!\n
@privateip
privateip / gist:567c8b32c082b5560085
Created March 28, 2016 02:44
Simple playbook to run commands on OpenSwitch from Ansible
---
- hosts: ops01
gather_facts: no
vars:
cli:
host: "{{ inventory_hostname }}"
port: 2222
username: netop
password: netop
---
- name: configure vty settings
hosts: ios
connection: local
gather_facts: no
tasks:
- name: set vty settings
ios_config:
lines:
---
- name: show mac address-table
register: output
nxos_command:
commands:
- show mac address-table | json
provider: "{{ cli }}"
register: output
- name: copy output to file
(ansible)[ansible-ios]$ ansible -m ios_command -a "host={{ inventory_hostname }} username=cisco password=cisco commands='show interfaces'" --connection local ios
ios02 | SUCCESS => {
"changed": false,
"stdout": [
"GigabitEthernet0/0 is up, line protocol is up \n Hardware is iGbE, address is fa16.3e50.7f24 (bia fa16.3e50.7f24)\n Description: OOB Management\n Internet address is 172.26.4.31/24\n MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec, \n reliability 255/255, txload 1/255, rxload 1/255\n Encapsulation ARPA, loopback not set\n Keepalive set (10 sec)\n Full Duplex, Auto Speed, link type is auto, media type is RJ45\n output flow-control is unsupported, input flow-control is unsupported\n ARP type: ARPA, ARP Timeout 04:00:00\n Last input 00:00:00, output 00:00:00, output hang never\n Last clearing of \"show interface\" counters never\n Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0\n Queueing strategy: fifo\n Output queue: 0/40 (size/max)\n 5 minute
@privateip
privateip / gist:88b68576d7c0dd8d8e566ce3ec75e4a8
Created August 11, 2016 23:24
asa_command show version
(ansible)[ansible-asa]$ ansible --version
ansible 2.2.0 (working 7579df33ce) last updated 2016/08/10 15:39:41 (GMT -400)
lib/ansible/modules/core: (working f3e761f0c8) last updated 2016/08/11 11:19:11 (GMT -400)
lib/ansible/modules/extras: (working 57c142b6ed) last updated 2016/08/02 15:17:56 (GMT -400)
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
(ansible)[ansible-asa]$
(ansible)[ansible-asa]$
(ansible)[ansible-asa]$
(ansible)[ansible-asa]$ cat show.yaml
@privateip
privateip / gist:11b042e569585ee9248a
Last active August 24, 2016 19:30
Super simple show version task
---
- hosts: ios_routers
gather_facts: false
connection: local
tasks:
- name: run show version on ios device
ios_command:
commands:
- show version
---
- hosts: ios01
connection: local
tasks:
- ios_facts:
host: "{{ inventory_hostname }}"
username: cisco
password: cisco
register: output