Skip to content

Instantly share code, notes, and snippets.

View supercow's full-sized avatar

James Sweeny supercow

View GitHub Profile
notice "1 imported"
import "2.pp"
@supercow
supercow / init.pp
Last active December 15, 2015 21:09
# /etc/puppetlabs/puppet/users/init.pp
class users {
$users_list = hiera('users::users_list')
users::user { $users_list: }
}
use console_inventory_service;
select r.restype 'Resource',r.title 'Title',h.name 'Exporting Host'
from resources as r
left join hosts as h on h.id = r.host_id
where r.exported=1
package { 'A':
ensure => $version,
}
if $::package_a_version != $version {
exec { 'do something reasonable':
subscribe => Package['A'],
notify => Resource['the_next_thing'],
}
}
notice: /Stage[main]//File[/tmp/${::uptime_seconds}]/ensure: created
err: /Stage[main]//Service[fail_on_refresh]: Failed to call refresh: Could not restart Service[fail_on_refresh]: Execution of '/bin/false' returned 1: at /root/service.pp:12
notice: /Stage[main]//File[/tmp/doesnt_exist]/ensure: created
notice: Finished catalog run in 0.07 seconds
$base_packages = [
'git',
'tmux',
'weechat',
'nginx',
'monit',
'sshd',
]
package { $base_packages:
@supercow
supercow / kermit.example.com.json
Created June 24, 2013 16:42
JSON to YAML from the Hiera walkthrough
{
"ntp::restrict" : false,
"ntp::autoupdate" : false,
"ntp::enable" : true,
"ntp::servers" : [
"0.us.pool.ntp.org iburst",
"1.us.pool.ntp.org iburst",
"2.us.pool.ntp.org iburst",
"3.us.pool.ntp.org iburst"
]
$case_val = 'CamelCase'
$select_val = 'CamelCase'
case $case_val {
'camelcase': {
$case_str = 'not case sensitive'
}
'CamelCase': {
$case_str = 'case sensitive'
}
# Run the puppet agent hourly
cron { 'run puppet agent':
command => '/opt/puppet/bin/puppet agent -t',
user => 'root',
minute => fqdn_rand(60),
}
new_hash = Hash.new
hash_table.each_value do |val|
new_hash[val['group']] ||= Array.new
new_hash[val['group']] << val['fqdn']
end