Skip to content

Instantly share code, notes, and snippets.

View budgester's full-sized avatar

Martin Stevens budgester

View GitHub Profile
@budgester
budgester / 0_reuse_code.js
Last active September 2, 2015 15:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
input {
file {
type => "httpd"
path => "/var/log/httpd/*.log"
}
}
filter {
if [type] == "httpd" {
grok {
-----> Starting Kitchen (v1.10.0)
-----> Converging <default-centos-67>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 4.3.5...
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to <default-centos-67>
dsc_resource 'Change User on TeamCity Agent Service' do
resource :service
property :ensure, 'Present'
property :name, SERVICE_NAME
property :credential, ps_credential("test@domain", "password")
end
@budgester
budgester / knife.rb
Created January 15, 2017 16:30 — forked from jtimberman/knife.rb
Commented knife.rb for all the things
# Knife Configuration File.
#
# This is a Ruby DSL to set configuration parameters for Knife's
# general options. The default location for this file is
# ~/.chef/knife.rb. If multiple Chef repositories are used,
# per-repository configuration files can be created. A per repository
# configuration file must be .chef/knife.rb in the base directory of
# the Chef repository. For example,
#
# ~/Development/chef-repo/.chef/knife.rb
function rsall() {
$@ -K ${RACKSPACE_API_KEY} -A ${RACKSPACE_USERNAME}
$@ -K ${RACKSPACE_API_KEY_1} -A ${RACKSPACE_USERNAME_1}
$@ -K ${RACKSPACE_API_KEY_2} -A ${RACKSPACE_USERNAME_2}
}
# Retrieve a secret, either from the env or from Vault
def self.secret(node, path)
# First, try in the environment
secret = AiHelper.environment_secret(node, path)
if secret.nil? || secret == 'IN_VAULT'
secret = AiHelper.vault_secret(node, path)
end
secret
end
#!/bin/bash
#
# vault-ec2-auth.sh
# Authenticates an EC2 instance to Hashicorp Vault
#
# configuration stored in environment variables in /etc/vault/client.conf
# expected configuration (defaults are selected below if none is specified):
# VAULT_ADDR = url of vault server
# VAULT_ROLE = role name to authenticate as
@budgester
budgester / gist:2106ecad0e73117d42f8dcf793c4f4b5
Created March 30, 2018 19:41
Inspec Docker with credentials file
docker run -it \
-e AWS_ACCESS_KEY_ID=$(aws --profile default configure get aws_access_key_id) \
-e AWS_SECRET_ACCESS_KEY=$(aws --profile default configure get aws_secret_access_key) \
-e AWS_REGION='eu-west-1' \
--rm \
-v $(pwd):/share \
chef/inspec exec aws-dev -t aws:
virtualenv -p python3 web
source web/bin/activate
deactivate