Instantly share code, notes, and snippets.

View alpha.j2
Alpha-file
{% for student in students %}
{{ lookup('template','beta.j2') }}
{%endfor%}
View vagrant_inventory.py
#!/usr/bin/env python
# Adapted from Mark Mandel's implementation
# https://github.com/ansible/ansible/blob/devel/plugins/inventory/vagrant.py
import argparse
import json
import paramiko
import subprocess
import sys
View vm_centos.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dnsLabelPrefix": {
"type": "string",
"metadata": {
"description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
}
},
View snippets.cson
This file has been truncated, but you can view the full file.
'.source.ansible':
'a10_server':
'prefix': "a10_server_snippet"
'description': "Manage A10 Networks AX/SoftAX/Thunder/vThunder devices' server object."
'body': """
a10_server:
username: ${1:null} # required. An account with administrator privileges.
host: ${2:null} # required. Hostname or IP of the A10 Networks device.
password: ${3:null} # required. Password for the C(username) account.
View vagrant.py
#!/usr/bin/env python
# Adapted from Mark Mandel's implementation
# https://github.com/ansible/ansible/blob/devel/plugins/inventory/vagrant.py
import argparse
import json
import paramiko
import subprocess
import sys
View rst_to_md.sh
FILES=*.rst
for f in $FILES
do
filename="${f%.*}"
echo "Converting $f to $filename.md"
`pandoc $f -f rst -t markdown -o $filename.md`
done
View update_ubuntu1804_libvirt.sh
#!/bin/bash
# Make sure libguestfs-tools package is installed (libguestfs-tools-c on EL)
# Make sure current user is in kvm group: sudo usermod $USER -g kvm OR sudo chmod 0666 /dev/kvm
# Based on https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one
box=ubuntu1804
provider=libvirt
if [[ $EUID > 0 ]]; then
echo "Please run as root/sudo"
exit 1
View Vagrantfile
Vagrant.configure("2") do |config|
config.vm.define "pfsense" do |subconfig|
subconfig.vm.box = "kennyl/pfsense"
subconfig.vm.box_version = "2.4.0"
subconfig.vm.synced_folder ".", "/vagrant", disabled: true
subconfig.vm.network "private_network", virtualbox__intnet: "mynetwork", auto_config: false
subconfig.vm.network "forwarded_port", guest: 80, host: 8080
subconfig.vm.network "forwarded_port", guest: 443, host: 8443
subconfig.vm.network "forwarded_port", guest: 3000, host: 3000
subconfig.vm.provider :virtualbox do |vb|
View play.yml
---
- name: Auto create dictionary
hosts: [localhost]
connection: local
vars:
ansible_tower:
towers_amount: 3 # Make sure this is uneven
databases_amount: 1 # Make sure this is uneven
prefix: 172.17.202.64/26
tasks:
View async.yml
---
- hosts: localhost
connection: local
tasks:
- name: simulate long running op, allow to run for 16 sec, fire and forget
command: "/bin/sleep {{ item }}"
async: 16
register: my_async_job
poll: 0
loop: [1, 3, 15, 4]