View ansible-vault-usage-example
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
View describe_instances.py
# 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()
View xpath_junos_primary_loopback
//logical-interface[name='lo0.0']/address-family[address-family-name='inet']/interface-address[ifa-flags/ifaf-current-primary]/ifa-local
View pyez_get_config_rpc.py
# 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)
View get-candidate-config.yml
# 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
View pyez_config_filtering.py
# 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()
View simple_test_v2.robot
*** 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 ***
View simple_test.robot_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
View logger_example.py
import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG,
format='%(asctime)s.%(msecs)d %(levelname)s %(module)s - %(funcName)s: %(message)s',
datefmt="%Y-%m-%d %H:%M:%S")
logging.debug("Here is a debug-level message")
View Dockerfile
# based on Duke Dougal's post at http://superuser.com/questions/844101/docker-login-via-ssh-always-asks-for-password
FROM ubuntu:trusty
ENV USER ubuntu
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN adduser --disabled-password --gecos "" $USER
RUN adduser $USER sudo
ADD authorized_keys /home/$USER/.ssh/authorized_keys
RUN chown $USER /home/$USER/.ssh/authorized_keys
RUN chown -R $USER:$USER /home/$USER/.ssh/authorized_keys