Skip to content

Instantly share code, notes, and snippets.

@daviddyball
daviddyball / ossec.sls
Last active December 12, 2015 09:49
Trying to get a one-time state for installing OSSEC. It only needs to run once... but the logic I've implemented doesn't seem to be working as planned. Any pointers?
% set version = '2.6' -%}
{% set ossecdir = 'ossec-hids-{0}'.format(version) -%}
ossec-install-working-dir:
file.directory:
- name: /tmp/ossec-install
ossec-download-installer:
file.managed:
- source: salt://ossec/files/{{ ossecdir }}.tar.gz
@daviddyball
daviddyball / 0-top.sls
Last active December 15, 2015 05:49
SaltStack Pillar Overrides
base:
'*':
- default-values
'salt-test':
- servers.salt-test
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": [
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 ...
@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)
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "USAGE: $0 plugin1 plugin2 ..."
exit 1
fi
plugin_dir=/var/lib/jenkins/plugins
@daviddyball
daviddyball / IAM_Role.json
Last active July 25, 2021 05:39
EC2 Metadata Script to Load a bootstrap script from S3 based on EC2 Tag Definitions
{
"Statement": [
{
"Sid": "EC2DescribeInstances",
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeTags"
],
"Resource": [
@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
}
@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"
#!/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