Skip to content

Instantly share code, notes, and snippets.

View privateip's full-sized avatar

Peter Sprygada privateip

View GitHub Profile
@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-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:d0fd3c6459c5e1a4c1f9dceeb018b109
Created October 2, 2016 01:26
playbook to backup network device running configuration to local file
---
- hosts: ios
connection: local
vars:
backup_root: /tmp/backups
cli:
host: "{{ inventory_hostname }}"
username: cisco
@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
@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