Skip to content

Instantly share code, notes, and snippets.

<% if @test -%>
command0
<%- if @test2 -%>
command1
command2
command3
<%- end -%>
<%- end -%>
class sqlite {
file{'/usr/local/share/myschema.sql':
ensure => file,
content => file('sqlite/myschema.sql')
}
exec{'sqllite3 /path/to/db.sql < /usr/local/share/myschema.sql':
refreshonly => true
subscribe => File['/usr/local/share/myschema.sql']
}
}
@b4ldr
b4ldr / chain.pp
Last active April 14, 2020 14:18
$chain = @("CHAIN")
${file('/tmp/foo.pem')}
${file('/tmp/bar.pem')}
| CHAIN
notice($chain)
profile::bacula::myclass::mydefines:
foobar:
abc: some value
class rundeck_server {
class { 'rundeck':
package_ensure => latest,
#grails_server_url => "https://${facts['ip']}",
grails_server_url => "http://127.0.0.1:4440",
key_storage_type => 'file',
projects_storage_type => 'db',
jvm_args => '-Dserver.http.host=0.0.0.0',
database_config => {
type => 'mysql',
# this will create the sysctl fragment if it dosn;t exist or changes
# If the resource changes i.e. the first time its written or you change the value
# sysctl -p will be called to write al the sysctl values
# however a module from the forge may be better i have used the following in the past
# https://forge.puppet.com/thias/sysctl
# however that is old and the following newer one may be better
# https://forge.puppet.com/herculesteam/augeasproviders_sysctl
sysctl::internals::add_sysctl_fragment { "${name}":
target => $target,
@b4ldr
b4ldr / test.pp
Last active February 21, 2020 17:21
~ $ grep -v ^# test.pp
$loc = 'ab1'
$arr = ['foo-ab1', 'bar-ab1', 'foo-ab1bar', 'bar-ab1$', 'foo-xz1', 'bar-xz1']
$new_arr = $arr.filter |$items| { $items !~ "-${loc}$" }
notify {$new_arr:}
~ $ puppet apply test.pp
Notice: Compiled catalog for work-laptop.home.arpa in environment production in 0.02 seconds
Notice: foo-ab1bar
Notice: /Stage[main]/Main/Notify[foo-ab1bar]/message: defined 'message' as 'foo-ab1bar'
@b4ldr
b4ldr / site.pp
Created February 21, 2020 14:32
package{'fail2ban':
ensure => installed,
}
class gobgp (
String $config_content,
stdlib::Unixpath $config_file = '/etc/gobgp.conf'
) {
ensure_packages(['gobgp'])
file{$config_file,
ensure => file,
content => $config_content,
notify => Service['gobgp']
require => Package['gobgp']
disks => {
nvme0n1 => {
model => "INTEL SSDPEKKF512G8L",
size => "476.94 GiB",
size_bytes => 512110190592
},
sda => {
model => "SD/MMC CRW",
size => "0 bytes",
size_bytes => 0,