This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the format of a puppet resource | |
resource_type { 'resource title': | |
ensure => 'the state I want the resource to exist in', | |
property1 => value, | |
property2 => value, | |
property3 => value, | |
} | |
# a silly example that might go on a job listing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
:backends: | |
- yaml | |
:yaml: | |
:datadir: /etc/puppetlabs/code/hieradata | |
:hierarchy: | |
- "%{::trusted.certname}" | |
- "%{environment}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file { '/etc/motd': | |
ensure => file, | |
content => 'What I expect in the motd', | |
} | |
concat { '/etc/motd': | |
ensure => present, | |
} | |
concat::fragment { 'motd header': | |
target => '/etc/motd', | |
order => '01', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Puppet::Parser::Functions.newfunction(:local_scope, | |
:type => :rvalue, | |
:doc => <<-'EOS' | |
Generates the local scope as a hash. This allows you to use epp functions more | |
or less like erb templates by passing local scope as the parameters argument. | |
e.g., `content => epp('mymodname/template.epp', local_scope() )` | |
EOS | |
) do |args| | |
scope = self.to_hash | |
scope.reject! { |key,val| scope['facts'].include? key } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this blows up with Error while evaluating a Resource Statement, Could not find stage last specified by Class[Test] | |
class {'test': | |
stage => 'last', | |
msg => 'boo', | |
} | |
stage { 'last': } | |
Stage['main'] -> Stage['last'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this blows up with Error while evaluating a Resource Statement, Could not find stage last specified by Class[Test] | |
class {'test': | |
stage => 'last', | |
msg => 'boo', | |
} | |
stage { 'last': } | |
Stage['main'] -> Stage['last'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Press the 'show relationships' button | |
# to see how these classes relate to one another | |
class outside { | |
include floater # this class is uncontained, so it will "float" outside the graph | |
contain contained # this class is contained, so it will be enforced within the parent class | |
require required # this class is required, so all we know is that it will be enforced before the parent class | |
} | |
class floater { | |
file { '/tmp/foo': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = [1,2,3,3,3,8,5,4,2,2,] | |
$dupes = $data.reduce |$memo, $value| { | |
if count($data, $value) > 1 { | |
[$memo, $value] | |
} | |
else { | |
[$memo] | |
} | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['192.168.1.24','192.168.1.25'].each |$ipaddress| { | |
firewall_rule { "Allow HTTP access to ${ipaddress}": | |
source_ip = $ipaddress, | |
destination_port = 80, | |
protocol = 'tcp', | |
} | |
} |