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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / ansible_ad_hoc_inventories.md
Created June 20, 2018 12:29 — forked from alces/ansible_ad_hoc_inventories.md
Using Ad-hoc Inventories in Ansible

In case you want to run ansible (or ansible-playbook) command against a set of hosts that makes sense only for one run, you can don't bother to create one-time inventory file, but simply define a comma-separated list of hosts as argument of --invertory option (or its short form that's simply -i) as follows:

ansible --inventory=myhost1,myhost2,myhost3 all -m setup -a 'filter=*name*'

(note that all in this command line stands for the target hostname)

If you have only one host to run your playbook against, your inventory string must ends with ,

@versionsix
versionsix / out.rsc
Created June 3, 2018 14:27
Mikrotik ipv6 default firewall
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
@versionsix
versionsix / parse.sh
Last active June 9, 2023 16:10
Azure BASH parse connection string example
#!/bin/bash
declare -x MYSQLCONNSTR_MS_Mysql="Database=mydevwiki; Data Source=mw-mysql; User Id=root; Password=mysecretpassword"
declare -A mysqlconn
# Strip spaces, then convert semicolon to spaces to loop in array
# We must strip spaces since this is inconsistent used inside azure
for keyvaluepair in $(echo $MYSQLCONNSTR_MS_Mysql | sed "s/ //g; s/;/ /g")
do
ARR=(${keyvaluepair//=/ })
mysqlconn[${ARR[0]}]=${ARR[1]}