Skip to content

Instantly share code, notes, and snippets.

View versionsix's full-sized avatar
🦖
Using modern software.

Frank Meeusen versionsix

🦖
Using modern software.
  • Belgium, Antwerp
View GitHub Profile
@versionsix
versionsix / farg.sh
Created June 29, 2018 12:34
Bash: Argument Parsing
#!/bin/bash
PARAMS=""
while (( "$#" )); do
case "$1" in
-1|--flag-with-argument-1)
F_ARG_1=$2
shift 2
;;
-2|--flag-with-argument-2)
F_ARG_2=$2
@versionsix
versionsix / Vagrantfile
Last active July 5, 2018 16:35
Vagrant 2 machines and ansible
# Ansible config see https://www.vagrantup.com/docs/provisioning/ansible_common.html#extra_vars
Vagrant.configure(2) do |config|
config.vm.define "machine-a" do |subconfig|
subconfig.vm.box = "generic/centos7"
subconfig.vm.hostname = "machine-a.local"
subconfig.vbguest.auto_update = false
subconfig.vm.network :private_network, ip: "192.168.199.101"
subconfig.vm.provider :virtualbox do |vb|
vb.memory = 1024
@versionsix
versionsix / update_centos7.sh
Last active July 6, 2018 12:05
Vagrant add local updated centos7 image
#!/bin/bash
# Based on https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one
mkdir -p centos7_box
cd centos7_box
touch Vagrantfile
cat << EOF > Vagrantfile
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
config.vm.box = "centos/7"
@versionsix
versionsix / async.yml
Created July 12, 2018 10:11
Ansible async task snippet
---
- 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]
@versionsix
versionsix / play.yml
Created July 13, 2018 08:59
Ansible dynamically generate ipam + inventory names based on single integer
---
- 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:
@versionsix
versionsix / Vagrantfile
Last active July 14, 2018 18:46
Vagrant pfsense + guest vm.
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|
@versionsix
versionsix / update_ubuntu1804_libvirt.sh
Last active July 16, 2018 14:40
Vagrant add local updated ubuntu version for libvirt provider
#!/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
@versionsix
versionsix / rst_to_md.sh
Created July 17, 2018 13:19 — forked from zaiste/rst_to_md.sh
Convert RST to Markdown using Pandoc
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
@versionsix
versionsix / vagrant.py
Created July 18, 2018 11:13 — forked from lorin/vagrant.py
Vagrant dynamic inventory script for Ansible
#!/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
@versionsix
versionsix / snippets.cson
Created July 18, 2018 13:25
atom ansible snippets
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.
server_name: ${4:undefined} # required. The SLB (Server Load Balancer) server name.