Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python2
# 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.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@daviddyball
daviddyball / docker.yml
Created June 24, 2015 17:48
docker play for custom registry
- docker:
name: my-container
image: my-image:latest
registry: https://my-private-repo:443/v2/
detach: true
command: bash -lc "while true; do sleep 1; done"
@daviddyball
daviddyball / common.py
Created June 22, 2015 18:07
Usefull filters for ansible
def split_string(*a, *kwargs):
return split(a[1],a[0])
class FilterModule(object):
def filters(self):
return {
'split_string': split_string
}
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "USAGE: $0 plugin1 plugin2 ..."
exit 1
fi
plugin_dir=/var/lib/jenkins/plugins
@daviddyball
daviddyball / docker_publish_yaml_v1
Last active August 29, 2015 14:05
Yaml configuration for drone docker-plugin
deploy:
docker:
docker_file: Dockerfiles/staging // Optional. Defaults to ./Dockerfile
docker_server: 192.168.125.10 // Required
docker__port: 5672 // Optional. Defaults to 2375
registry_host: docker.mycompany.com // Optional. If missing will push to index.docker.io
registry_protocol: https // Optional. Defaults to http
registry_port: 443 // Optional.
registry_login_uri: /somewhere/random/v1/ // Optional. Defaults to /v1/ (some people override it)
rhs_top = ListBox(..)
rhs_bottom = ListBox(..)
rhs = Pile([ lhs_top, lhs_bittom ])
lhs = ListBox(..)
columns = Columns([ lhs, rhs])
frame = Frame(columns)
loop = MainLoop(frame)
... Later on ...
Try this - it requires that you have the AWS command line tools installed and that your instance has either been assigned an IAM role with sufficent permissions, or that your AWS command line tools have been set up with the right credentials. You should use IAM roles if you want to get this info at first boot, which I suspect is what you want to use this for?
aws ec2 describe-instances --region eu-west-1 --output text --instance-ids `curl -s http://169.254.169.254/latest/meta-data/instance-id` | grep TAGS
If you create an IAM role called AllowDescribeInstances with the following policy this and assign it to your instances, this is the minimum permissions set that is required.
{
"Version": "2012-10-17",
"Statement": [