Skip to content

Instantly share code, notes, and snippets.

View willthames's full-sized avatar

Will Thames willthames

View GitHub Profile
#!/usr/bin/env python
import collections
import json
import os
import sys
''' location returns the location portion of the hostname '''
def location(host):
$ ansible-playbook playbook.yml -i testlocal -e remote_host=testlocal
PLAY [localhost] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [command] *****************************************************************
fatal: [localhost -> testlocal]: FAILED! => {"changed": false, "failed": true, "module_stderr": "/bin/sh: {{: command not found\n", "module_stdout": "", "msg": "MODULE FAILURE"}
to retry, use: --limit @/home/will/tmp/ansible/playbook.retry
ANSIBLE_DEBUG=1 ansible-inventory --list -i inventory/cluster.config
13396 1509411881.86061: starting run
13396 1509411881.94683: Added group all to inventory
13396 1509411881.94690: Added group ungrouped to inventory
13396 1509411881.94695: Group all now contains ungrouped
13396 1509411881.94806: Loading InventoryModule 'host_list' from /home/will/src/ansible/lib/ansible/plugins/inventory/host_list.py (searched paths: /home/will/src/ansible/lib/ansible/plugins/inventory:/home/will/src/errcd-ansible/plugins/inventory)
13396 1509411881.94827: Loading InventoryModule 'script' from /home/will/src/ansible/lib/ansible/plugins/inventory/script.py (searched paths: /home/will/src/ansible/lib/ansible/plugins/inventory:/home/will/src/errcd-ansible/plugins/inventory)
13396 1509411881.94845: Loading InventoryModule 'yaml' from /home/will/src/ansible/lib/ansible/plugins/inventory/yaml.py (searched paths: /home/will/src/ansible/lib/ansible/plugins/inventory:/home/will/src/errcd-ansible/plugins/inventory)
13396 150
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
name: generator
plugin_type: inventory
version_added: "2.5"
- block:
- name: set yaml anchor
set_fact:
aws_connection_info: &aws_connection_info
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ security_token }}"
no_log: yes
- name: create WAF IP match
@willthames
willthames / README.md
Created April 17, 2018 23:13
aws_ec2.py for use with ansible 2.5.0 (works as expected with 2.5.1 onwards)

Put the aws_ec2.py file into e.g. plugins/inventory

Ensure ansible.cfg contains the following settings:

[defaults]
inventory_plugins = plugins/inventory

[inventory]
enable_plugins = aws_ec2,host_list,script,yaml,ini
/**
https://www.reddit.com/r/firefox/comments/726p8u/multirow_tabs_firefox_ignores_mozboxflex/dngb8qf/
*/
.tabbrowser-tab:not([pinned]) {
flex-grow:1;
min-width:150px;
}
.tabbrowser-tab,.tab-background {
@willthames
willthames / kops1.yml
Created October 30, 2018 23:41
hooks definition for kubectl drain service in kops
hooks:
- execContainer:
command:
- sh
- -c
- chroot /rootfs curl -LsO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl && chroot /rootfs install -m 755 kubectl /usr/local/bin/kubectl
image: busybox
roles:
- Node
- name: kubectl-drain.service
@willthames
willthames / kubedrain-rbac.yml
Created October 30, 2018 23:42
kubedrain ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubedrain
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- apiGroup: rbac.authorization.k8s.io
@willthames
willthames / kops2.yml
Created October 30, 2018 23:43
acpi-support installation hook for kops
- execContainer:
command:
- sh
- -c
- >
chroot /rootfs apt-get update &&
DEBIAN_FRONTEND=noninteractive chroot /rootfs
apt-get install -y --force-yes -o Dpkg::Options::="--force-confdef" acpi-support
image: busybox
roles: