Skip to content

Instantly share code, notes, and snippets.

View supercow's full-sized avatar

James Sweeny supercow

View GitHub Profile
$hosts = ['hosta','hostb','hostc']
range(0,count($hosts)-1).each |$num| {
$port = 8080 + $num
somemodule::someservice { $hosts[$num]:
listening_port => $port,
}
}
Notice: Scope(Class[main]): String
Notice: Compiled catalog for stout.4c in environment production in 0.03 seconds
Notice: Finished catalog run in 0.02 seconds
---
parent::params:
- example1
- example2
class parent1 {
include child1
anchor { 'parent1::start': } ->
Class['child1'] ->
anchor { 'parent1'::end': }
}
class parent2 {
include child2
anchor { 'parent2::start': } ->
new_hash = Hash.new
hash_table.each_value do |val|
new_hash[val['group']] ||= Array.new
new_hash[val['group']] << val['fqdn']
end
# Run the puppet agent hourly
cron { 'run puppet agent':
command => '/opt/puppet/bin/puppet agent -t',
user => 'root',
minute => fqdn_rand(60),
}
$case_val = 'CamelCase'
$select_val = 'CamelCase'
case $case_val {
'camelcase': {
$case_str = 'not case sensitive'
}
'CamelCase': {
$case_str = 'case sensitive'
}
@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"
]
$base_packages = [
'git',
'tmux',
'weechat',
'nginx',
'monit',
'sshd',
]
package { $base_packages:
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