Skip to content

Instantly share code, notes, and snippets.

View gsuite.py
#!/usr/bin/env python3
"""A simple example of how to access the Google Analytics API."""
from argparse import ArgumentParser
from apiclient.discovery import build
from google.oauth2 import service_account
def get_args():
View foo.rb
class Foo
@@count = 1
def self.count
@@count
end
def self.increment
@@count += 1
end
end
Puppet::Functions.create_function(:'test::foo') do
View test.pp
class resolv {
case $hostname {
/^[Abc]/: {
resolv::resolv_config { 'Default':
domain => "mydomain.local",
}
}
}
}
View bash.sh.erb
<% if @test -%>
command0
<%- if @test2 -%>
command1
command2
command3
<%- end -%>
<%- end -%>
View sqlite.pp
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']
}
}
View chain.pp
$chain = @("CHAIN")
${file('/tmp/foo.pem')}
${file('/tmp/bar.pem')}
| CHAIN
notice($chain)
View data.yaml
profile::bacula::myclass::mydefines:
foobar:
abc: some value
View rundeck.pp
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',
View sysctl.pp
# 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,
View test.pp
~ $ 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'
You can’t perform that action at this time.