Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View privateip's full-sized avatar

Peter Sprygada privateip

View GitHub Profile
@privateip
privateip / gist:879683a0172415c408fb2afb82a97511
Created April 26, 2018 19:34
how to use ansible runner programatically
import os
import json
import tempfile
import subprocess
import ansible_runner
def run():
# create an Ansible playbook as a native Python dict object. Currently
@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:04683a832259e4a7ffb7a5720b4d1c2c
Last active June 7, 2019 12:31
Test of Ansible Junos Netconf functionality with 2.8.0
################ INVENTORY FILE ############################################3
(ansible) [ansible-junos]$ cat inventory
[all:vars]
ansible_python_interpreter=python
[junos]
an-vsrx-02.ansible.eng.rdu2.redhat.com
[junos:vars]
ansible_network_os=junos
# (c) 2016 Red Hat Inc.
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = """
---
author: Ansible Networking Team
---
- src: ansible-network.network-engine
- src: https://github.com/ansible-network/arista_eos
name: ansible-network.arista_eos
- src: https://github.com/ansible-network/cisco_ios
name: ansible-network.cisco_ios
(ansible) [~]$
import paramiko
user = raw_input('Username: ')
password = raw_input('Password: ')
name = raw_input('Hostname: ')
command = raw_input('Command: ')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@privateip
privateip / gist:2ab7bfc7b93eafe004d17bf21edc1f51
Created January 23, 2018 20:31
example netconf with native connection
#!/usr/bin/python
# (c) 2018, Red Hat, Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
- hosts: an-nios-01
gather_facts: no
connection: local
vars:
provider:
host: an-nios-01.ansible.eng.rdu2.redhat.com
username: admin
password: admin
@privateip
privateip / gist:60b0a58721fd6b4354e8b5f5618bb15b
Created November 27, 2017 22:14
Example of network_cli

Example of network_cli

Updated: 27-Nov-2017

As the Ansible network team begins the transition towards implementing the network_cli connection plugin, we wanted to provide a sample implementation for module developers to use as a guide.

The document provides details on how to implement a module using the new

@privateip
privateip / gist:27177caa90005a59219c91bffeeac3d5
Created November 27, 2017 22:07
example ios implementation of network_cli
(ansible) [ansible-ios]$ play example.yaml -u ansible -k -vvv
ansible-playbook 2.5.0 (network-cli-example 5c88db3630) last updated 2017/11/27 16:18:59 (GMT -400)
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/sprygada/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /home/sprygada/Workspaces/ansible/lib/ansible
executable location = /home/sprygada/Workspaces/ansible/bin/ansible-playbook
python version = 2.7.14 (default, Nov 3 2017, 10:55:25) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]
Using /etc/ansible/ansible.cfg as config file
SSH password:
Parsed /etc/ansible/hosts inventory source with ini plugin