Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
😏

Matt Martz sivel

😏
View GitHub Profile
@sivel
sivel / server_list_generator.py
Last active August 29, 2015 14:05
pyrax server list generator
#!/usr/bin/env python
import pyrax
pyrax.set_setting('identity_type', 'rackspace')
pyrax.set_credentials('myusername', 'myapikey', region='DFW')
def server_list_generator(detailed=True, search_opts=None, limit=None):
servers = pyrax.cloudservers.servers.list(detailed=detailed,
search_opts=search_opts,
limit=limit)
certs:
www_example_com:
key: |
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA0cfBegr0ahA1PXrF3fBJURcBxoP8PZow1a6tRGe3ruJZBMSH
vx2+dm2Sq3bCPHH2hUkC0Oj2U+54WMzn22ZwVsgOPG7ks1EqKy48K5VPrWDMJqjn
MhxLpTaf6xaGUlkVA6xcO5+SNFqzkq8fFWSHmY+E3n03ym0zH/Loy1KYRI0xVPRq
ITp7AoPbJ58Lz1X9CgBd7siaVjPvaS6WfosLwlI8gr1h6vqeO7nPrF8B9HnV7867
bSZlkbb6vqgtLg73B4diRGvNn5X9Kpsi1jbp7DAXHj2pGA8kr8TjV6MG28Di/iWL
oyiBDziIHe7iV0my+wl12x6o5JTuVVMkbD57AQIDAQABAoIBAB3ysoBFyBbMMY2R
@sivel
sivel / drone.sh
Created September 18, 2014 02:13
Drone on RHEL6
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install -y golang git mercurial make bzr
export GOPATH=~/Go
export PATH=$PATH:$GOPATH/bin
mkdir $GOPATH
go get github.com/drone/drone
cd $GOPATH/src/github.com/drone/drone
make deps
make vendor
make clean
@sivel
sivel / email-cmd.py
Created March 20, 2015 00:07
email-cmd.py ansible callback plugin
import os
import sys
import smtplib
def mail(subject='Ansible Command', sender='<root>', to='root', cc=None,
bcc=None, body=None):
if not body:
body = subject
@sivel
sivel / ansible-validate-modules
Last active August 29, 2015 14:21
Ansible module validator
pip install git+https://github.com/ansible/ansible.git@devel#egg=ansible
pip install git+https://github.com/sivel/ansible-testing.git#egg=ansible_testing
git clone https://github.com/ansible/ansible-modules-core.git
ansible-validate-modules ansible-modules-core
@sivel
sivel / paramiko-keyscan.py
Created May 19, 2015 18:58
Python Paramiko Keyscan
import paramiko
# provide host and port variables
t = paramiko.transport.Transport('%s:%s' % (host, port))
t.start_client()
key = t.get_remote_server_key()
if int(port) != 22:
host = '[%s]:%s' % (host, port)
@sivel
sivel / rackspace.py
Last active August 29, 2015 14:23
python-openstacksdk Rackspace API Key Authenticator
from openstack.auth.identity.v2 import Password
class ApiKey(Password):
valid_options = {
'access_info',
'auth_url',
'username',
'user_id',
'password',
@sivel
sivel / etc_hosts.py
Created June 22, 2015 18:45
Ansible inventory script that uses /etc/hosts as it's data source
#!/usr/bin/env python
# (c) 2015, Matt Martz <matt@sivel.net>
#
# This file is part of Ansible.
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@sivel
sivel / go-build.sh
Last active September 28, 2023 18:40
Ansible Binary Golang Module
go build helloworld.go
GOOS=windows GOARCH=amd64 go build helloworld.go
diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py
index 1804a03..3703062 100644
--- a/lib/ansible/playbook/play_context.py
+++ b/lib/ansible/playbook/play_context.py
@@ -80,6 +80,13 @@ MAGIC_VARIABLE_MAPPING = dict(
su_flags = ('ansible_su_flags',),
)
+MAGIC_VARIABLE_UNDEFINED = [
+ 'remote_addr',