Skip to content

Instantly share code, notes, and snippets.

View jeffbrl's full-sized avatar

Jeff Loughridge jeffbrl

View GitHub Profile
@jeffbrl
jeffbrl / simple_test.robot_v1
Last active February 22, 2017 16:55
Simple test of a calculator function with the robot framework - v1
*** Settings ***
Documentation Check arithmetic operations
Library ${EXECDIR}/lib/easy_math.py WITH NAME math
# The setup and teardown functions currently only print messages to output.xml
Suite Setup math.setup
Suite Teardown math.teardown
@jeffbrl
jeffbrl / simple_test_v2.robot
Last active October 26, 2021 15:40
Simple test of a calculator function with the robot framework - v2
*** Settings ***
Documentation Check arithmetic operations
Resource ${EXEC_DIR}/resources/keywords.txt
# currently only prints to output.xml
Suite Setup math.setup
Suite Teardown math.teardown
*** Variables ***
@jeffbrl
jeffbrl / pyez_config_filtering.py
Created March 10, 2017 12:31
PyEZ config filtering example
# Pulled from Google Groups post by Stacy Smith
# https://groups.google.com/forum/#!topic/junos-python-ez/1OfnulLkyn4
import sys
import getpass
from lxml import etree
from jnpr.junos.device import Device
# Python3 is input(), Python2 is raw_input()
@jeffbrl
jeffbrl / get-candidate-config.yml
Created March 16, 2017 18:00
Obtaining the candidate configuration from router
# This ansible playbook gets the candidation configuration
- name: Get configuration
hosts: all
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
- name: Getting router configs
@jeffbrl
jeffbrl / pyez_get_config_rpc.py
Created March 17, 2017 01:20
Using PyEZ's get_config RPC
# This gist demonstrates how to use PyEZ's get_config RPC
from jnpr.junos import Device
from lxml import etree
def example_one(dev):
# This uses default options
cnf = dev.rpc.get_config()
print etree.tostring(cnf)
@jeffbrl
jeffbrl / xpath_junos_primary_loopback
Created June 23, 2017 14:30
xpath expression for obtaining primary loopback address in junos
//logical-interface[name='lo0.0']/address-family[address-family-name='inet']/interface-address[ifa-flags/ifaf-current-primary]/ifa-local
@jeffbrl
jeffbrl / describe_instances.py
Created February 27, 2018 17:28
How to make datetime.datetime json serializable - boto3 ec2 describe_instances
# Adapted from https://stackoverflow.com/questions/35869985/datetime-datetime-is-not-json-serializable
import datetime
import json
import boto3
def datetime_handler(x):
if isinstance(x, datetime.datetime):
return x.isoformat()
@jeffbrl
jeffbrl / ansible-vault-usage-example
Created May 22, 2018 13:22
ansible-vault usage example using encrypted variables file
jeffl@ubuntu:~/vault_testing$ cat vars/secrets.yml
---
username: jeffl
password: secretpassword
jeffl@ubuntu:~/vault_testing$
jeffl@ubuntu:~/vault_testing$ echo "my_vault_pass" > vault_pass
jeffl@ubuntu:~/vault_testing$ chmod go-r vault_pass
jeffl@ubuntu:~/vault_testing$ ansible-vault encrypt --vault-id vault_pass vars/secrets.yml
@jeffbrl
jeffbrl / NetworkInterfaces.yaml
Created September 9, 2018 00:04
AWS CloudFormation NetworkInterfaces Syntax
# From https://stackoverflow.com/questions/47644034/cloudformation-error-value-of-property-networkinterfaces-must-be-a-list-of-obje
MyAppNetworkInterface:
Type: AWS::EC2::NetworkInterface
Properties:
SubnetId: !Ref SubnetPrivate
MyApp:
Type: AWS::EC2::Instance
Properties:
@jeffbrl
jeffbrl / userdata.sh
Last active August 8, 2023 21:14
AWS EC2 User Data for installing apache on Amazon Linux 2
#!/bin/bash -xe
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
find /var/www -type f -exec chmod 0664 {} \;