View lookup_sensitive.pp
function mymodule::my_privates (
Variant[String, Numeric] $key,
Hash $options,
Puppet::LookupContext $context,
) {
case $key {
'mymodule::secret1' : { Sensitive('There is no Santa on the evening coach') }
'mymodule::secret2' : { Sensitive('All your base are belong to us') }
default: { $context.not_found }
}
View rewritten.epp
<%-
$pin = "release a=${name}" # default value
if $pin_release.length > 0
$options = [
if $release.length > 0 { "a=${release}" },
if $codename.length > 0 { "n=${codename}" },
if $release_version.length > 0 { "v=${release_version}"},
if $component.length > 0 { "c=${component}" },
if $originator.length > 0 { "o=${originator}" },
if $label.length > 0 { "l=${label}" },
View default_content(1.8.7).rb
Puppet::Parser::Functions.newfunction(:default_content,
:type => :rvalue,
:doc => <<-'ENDOFDOC'
Takes an optional content and an optional template name and returns the
contents of a file.
Examples:
$config_file_content = default_content($file_content, $template_location)
file { '/tmp/x':
View exampleepp.pp
# Example of local variables set inside of an EPP template
#
$template = @(EOF)
<%
# this is an element with arbitrary puppet code
$hash = { a => 1, b => 2, c => 3 }
-%>
The keys are:
<%- $hash.each |$key, $value| { -%>
View my_first_puppet_validator.rb
require 'puppet'
# Example of a module setting everything up to perform custom
# validation of an AST model produced by parsing puppet source.
#
module MyValidation
module Issues
# (see Puppet::Pops::Issues#issue)
# This is boiler plate code
def self.issue (issue_code, *args, &block)
View gist:c300d021fee43f13779a7d5217e20820
a::x {
define b {}
}
should be written (as the 100% equivalent):
class a::x{
}
define a::x::b {
View abc_metric.rb
# AbcMetric sample - obviously in the wrong name space...
module Puppet::Pops
module Validation
class AbcMetric
attr_reader :assignment_count
def initialize()
@@abc_visitor ||= Visitor.new(nil, "abc", 0, 0)
@assignment_count = 0
View master-agent-from-source.md

Run Agent and Master from source on same machine

bundle exec puppet master --no-daemonize --certname localhost --dns_alt_names localhost --verbose
bundle exec puppet agent -t --certname localhost --server localhost

To re-set the CSR process for an agent:

View blog.pp
$data = {
persons => {
'Henrik' => {
mother => 'Anna-Greta',
father => 'Bengt',
},
'Anna-Greta' => {
mother => 'Margareta',
father => 'Harald',
children => ['Henrik', 'Annika']
View gist:3ee308e5470b98f563c7
$limited_sudo = hiera('staff::allowed::sudo', undef)
if ( $limited_sudo ) {
$allowed_sudo = $limited_sudo.reduce( false ) |$allowed_sudo, $entry[ {
$team = $entry[1]
case [$allowed_sudo, $team, $username in hiera($team)] {
[ false, /::team::/, true] : {
warning ("Allowing sudo")
warning ("1: true")
true
}