Skip to content

Instantly share code, notes, and snippets.

View cidrblock's full-sized avatar

Bradley A. Thornton cidrblock

View GitHub Profile
---
- name: test seassclrt001
ios_config:
host: "{{ inventory_hostname }}"
before: ['no ip access-list standard test']
parents: ['ip access-list standard test']
lines:
- permit 1.1.1.1
- permit 1.1.1.2
- permit 1.1.1.3
#1:49
diagram:
fill: "#3d3935"
columns: 5
rows: 5
gridLines: false
title:
color: lightgrey
heightPercentage: 6
logoFill: lightgrey
diagram:
fill: "white"
rows: 6
columns: 6
gridLines: true
title:
color: black
fill: none
logoFill: white
logoUrl: "https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg"
@cidrblock
cidrblock / gist:c163be2da9757e67a4fd5014f33948e5
Created November 1, 2016 11:46
Dockerfile for ansible + utilities
FROM ansible/ansible:ubuntu1604
# Some basic useful utilities not related to Ansible
RUN apt-get update && apt-get -y install vim wget cowsay
# Install govc, used for vsphere VM spinup
RUN curl -L -O https://github.com/vmware/govmomi/releases/download/v0.11.1/govc_linux_amd64.gz &&\
gunzip govc_linux_amd64.gz &&\
mv govc_linux_amd64 /usr/local/bin/govc &&\
chmod +x /usr/local/bin/govc
@cidrblock
cidrblock / Int64
Created November 2, 2016 11:34
snmpms.js
// Int64.js
//
// Copyright (c) 2012 Robert Kieffer
// MIT License - http://opensource.org/licenses/mit-license.php
/**
* Support for handling 64-bit int numbers in Javascript (node.js)
*
* JS Numbers are IEEE-754 binary double-precision floats, which limits the
* range of values that can be represented with integer precision to:
@cidrblock
cidrblock / ntp_health.py
Created November 21, 2017 19:16
Check the health of your ntp servers
""" ntpq out parser and reporter
"""
import re
import socket
# pylint: disable=redefined-builtin
from ansible.module_utils.basic import AnsibleModule
# - name: Run the ntp health module against the out from the ntp status command
# ntp_health:
# output: "{{ output['stdout'][0] }}" # the output of 'show ntp associations or show ntp peer-status'
@cidrblock
cidrblock / example_in_jinja.j2
Last active March 11, 2021 00:04
Add or remove vlans from a trunk port as needed
{# ############################################## fail if add, no longer supported #}
{% if 'add' in interface['value']['switchport']['trunk']['allowed_vlans'] %}
{{ you_cant_use_the_add_statement_anymore }}
{% endif %}
{# ############################################## remediate the trunk list #}
{% set trunk_vlan_changes = configuration_prechange['matches']['sections'][0]['section_content']|trunk_vlan_remediate(interface['value']['switchport']['trunk']['allowed_vlans']['vlans'],20) %}
{% if 'vlans' in trunk_vlan_changes and trunk_vlan_changes['vlans'] %}
{% set _ = desired.append("switchport trunk allowed vlan %s" % (trunk_vlan_changes['vlans'])) %}
{% endif %}{# vlans #}
{% for entry in trunk_vlan_changes['vlans_add'] %}
@cidrblock
cidrblock / showinventory.py
Created December 1, 2017 19:07
Dump the inventory for a device
#!/usr/bin/env python
import argparse
from ansible.parsing.dataloader import DataLoader
from ansible.vars.manager import VariableManager
from ansible.inventory.manager import InventoryManager
from cbkutils.utils import ppc
def collect(args):
""" Collect vars for a device
"""
@cidrblock
cidrblock / working.py
Created October 21, 2018 17:19
Fleet configuration management OO prototyping
""" fleet prototype
"""
import os
import multiprocessing.pool
from netmiko.ssh_autodetect import SSHDetect
from netmiko.ssh_dispatcher import ConnectHandler
class Configuration(): #pylint: disable=R0903
""" A class for a configuration
"""
@cidrblock
cidrblock / json2python.py
Created March 6, 2019 23:44
json schema to python object
import re
import python_jsonschema_objects as pjs
model = {
"title": "lldp",
"type": "object",
"properties": {
"neighbors": {
"type": "object",
"patternProperties": {