Skip to content

Instantly share code, notes, and snippets.

View privateip's full-sized avatar

Peter Sprygada privateip

View GitHub Profile
---
# This parser will parse the output from 'show running-config' on Cisco NXOS.
#
# Command: show running-config
# Platform: nxos
#
# Returns:
# interfaces:
# name: The name of the interface
# ipv4: The IPv4 address (if configured)
@privateip
privateip / gist:c5e39666e4d7675cc92e378118ac2e41
Created August 30, 2017 16:57
Retrieve partial junos config using junos_command + cli
(ansible) [ansible-junos]$ cat syslog.yaml
---
- hosts: vsrx01
connection: local
gather_facts: no
tasks:
- junos_command:
commands: show configuration system syslog
provider: "{{ cli }}"
#!/usr/bin/python
#
# 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 is distributed in the hope that it will be useful,
(ansible)[ansible-nxos]$ cat show.yaml
---
- hosts: nxos03
gather_facts: no
connection: local
tasks:
- name: return show commands output
nxos_command:
commands:
(ansible) [ansible-ios]$ grep ansible.log -e "^<"
<ios01> using connection network_cli
<ios01> ESTABLISH CONNECTION FOR USER: ansible on PORT 22 TO ios01
<ios01> Authentication failed.
<ios01> using connection network_cli
<ios01> ESTABLISH CONNECTION FOR USER: ansible on PORT 22 TO ios01
<ios01> shutting down control socket, connection was active for 0:00:59.872472 secs
<ios01> closing connection
<ios01> using connection network_cli
<ios01> ESTABLISH CONNECTION FOR USER: ansible on PORT 22 TO ios01
---
- name: Test SROS in lab
hosts: lab-12e
connection: local
vars:
cli:
host: "{{ inventory_hostname }}"
username: ansible
ssh_keyfile: /home/nkeeling/ansible/rsa-keys/ansible_rsa.pub
transport: cli
---
- name: demo playbook
hosts: all
gather_facts: no
connection: local
tasks:
- name: show version
eos_command:
commands: show running-config
---
- hosts: veos01
gather_facts: no
connection: local
vars:
eapi:
host: "{{ inventory_hostname }}"
username: admin
password: admin
@privateip
privateip / gist:c0e440c82dbb22ce0d88a3356156a100
Created September 30, 2016 14:43
changing default output for nxos_command
---
- hosts: nxos01
tasks:
- name: return native objects from cli
nxos_command:
commands:
- command: show version
output: json
provider: "{{ cli }}"
---
- hosts: ios01
connection: local
tasks:
- ios_facts:
host: "{{ inventory_hostname }}"
username: cisco
password: cisco
register: output