Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Autostart Libvirt VM's created with Foreman
# /usr/share/foreman/config/hooks/host/managed/create/10_autostart_libvirt.sh
# Source: http://www.uberobert.com/autostart-libvirt-vms-in-foreman/
. $(dirname $0)/hook_functions.sh
username='admin'
password='changeme'
@antaflos
antaflos / addUser.sh
Last active August 29, 2015 14:08 — forked from lemonlatte/addUser.sh
#!/bin/sh
dn='dc=math,dc=nccu,dc=edu,dc=tw'
username='jim.yeh'
uid='jim.yeh'
gid='student'
cat << EOF > user_example.ldif
dn: cn=$username,ou=users,ou=login,$dn
@antaflos
antaflos / haproxy.cfg
Last active August 29, 2015 14:06 — forked from rnewson/haproxy.cfg
# Bind SSL port with PFS-enabling cipher suite
bind :443 ssl crt path_to_certificate no-tls-tickets ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-RC4-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES128-SHA:AES256-SHA256:AES256-SHA:RC4-SHA
# Distinguish between secure and insecure requests
acl secure dst_port eq 443
# Mark all cookies as secure if sent over SSL
rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure if secure
# Add the HSTS header with a 1 year max-age

Test with External Function

When

You want to test a resource definition (class, defined type) that uses a function provided by a third-party module your module depends upon. It's supposed that you're implementing your tests with rspec-puppet.

How

echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo su - postgres -c "service postgresql stop"
sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"'
profile::iptables_default::rules_manage: true
profile::iptables_default::rule_file: /etc/sysconfig/iptables.TEST
profile::iptables_default::filter_chain_defaults:
table: filter
policy: ACCEPT
require: Iptables::Add_table['iptables_filter']
profile::iptables_default::filter_chains:
mydefaultfilterchains:
node default {
$role = hiera('role')
include "role::${role}"
}
$foo = undef
validate_string($foo)
@antaflos
antaflos / puppet agent -t
Created April 2, 2014 09:44
Facter 2.0.1, Puppet 3.4.3, Ubuntu 12.04 x86-64, environment=production_redux
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve local facts: undefined method `puppetversion' for Facter:Module
Error: Failed to apply catalog: Could not retrieve local facts: undefined method `puppetversion' for Facter:Module
@antaflos
antaflos / spec.rb
Created March 21, 2014 16:18
how to test for the default value of [] for `some_array_parameter`?
...
describe '#some_array_parameter' do
it 'should default to []' do
# ???
end
context 'the array parameter does something' do
let(:params) { { :some_array_parameter => [ 'foo', 'bar' ] } }
...
end