Skip to content

Instantly share code, notes, and snippets.

View mohclips's full-sized avatar

mohclips mohclips

View GitHub Profile
@mohclips
mohclips / jon1.yml
Last active October 24, 2021 21:56
how to loop through a dict with lists and dicts that reference other vars dicts
---
#!/usr/bin/env ansible-playbook
# vim: noai:ts=2:sw=2:et
# how to loop through a dict with lists and dicts that reference other vars dicts
# note that the dict keys dont have '-' but '_' so that jinja2 doesnt try and parse them as subtraction.
- name: Test for Jon
@mohclips
mohclips / brute-force_known_hosts.py
Created January 25, 2017 19:40
Brute force hashed known_hosts
import ipaddress
import os
import hashlib
import hmac
import base64
# markers (optional), hostnames, keytype, base64-encoded key, comment. The fields are separated by spaces.
# Hashed hostnames start with a | character. Only one hashed hostname may appear on a single line and none of the above negation or wildcard operators may be applied.
@mohclips
mohclips / a.yml
Last active January 25, 2017 22:06
Tags in include and blocks
# vim: noai:ts=2:sw=2:et
---
- name: "Test block tag include block tag"
hosts: localhost
connection: local
gather_facts: no
tasks:
ubuntu@nx-demo01-1b-jumpserver:~$ ansible-playbook --version
ansible-playbook 2.2.1.0
config file =
configured module search path = Default w/o overrides
@mohclips
mohclips / ansible-delegate.yml
Created January 28, 2017 12:28
Testing delegation to localhost
# vim: noai:ts=2:sw=2:et
---
- name: "testing hosts and delgation"
# ansible-playbook --connection=local -i "localhost,ubuntu" a.yml
hosts: all
gather_facts: no
@mohclips
mohclips / _output
Last active January 29, 2017 13:05
testing add_host across multiple plays in playbook
$ ansible-playbook test-add_host.yml
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [Play 1] ******************************************************************
TASK [Show inventory - play 1a] ************************************************
ok: [localhost] => {
"groups": {
"all": [],
@mohclips
mohclips / substring.yml
Last active January 29, 2017 22:32
Ansible sub-string and list tests
# vim: noai:ts=2:sw=2:et
---
- name: "substring/slices sorting tests"
hosts: localhost
vars:
servers:
apps:
@mohclips
mohclips / Vagrantfile-docker-ansible-manager
Created February 1, 2017 22:05
A Vagrantfile to create 4x ubuntu instances for Docker Swarm and 1x centos Ansible master
# -*- mode: ruby -*-
# vi: set ft=ruby :
# vim: noai:ts=2:sw=2:et
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
UBUNTU_BOX='ubuntu/trusty64'
CENTOS_BOX='centos/7'
@mohclips
mohclips / vRebuild.sh
Created February 2, 2017 07:29
rebuilds a named vagrant vm
#!/bin/bash
V=$1
containers=$(cat ~/.vagrant.d/data/machine-index/index | jq '.machines[] | {name} | to_entries[] | .value')
if [ $(echo $containers | grep -c \"$V\") -ne 1 ] ; then
echo "Can't find $V in container list"
echo $containers
exit 2
@mohclips
mohclips / shipyard-test.yml
Created February 6, 2017 20:19
Ansible - Check if Shipyard is installed as a docker image, if not install it
#
# Block to install Shipyard onto docker_swarm_manager - if required
#
- block:
- name: "Check if Shipyard is installed"
shell: docker ps | grep -c "shipyard/shipyard"
ignore_errors: yes
become: no
register: shipyard_test