Skip to content

Instantly share code, notes, and snippets.

View binford2k's full-sized avatar

Ben Ford binford2k

View GitHub Profile
@binford2k
binford2k / auth.pp
Last active June 26, 2018 17:58
authorization rule examples for some puppetserver API endpoints
puppet_authorization::rule { 'puppetlabs environment cache':
match_request_path => '/puppet-admin-api/v1/environment-cache',
match_request_type => 'path',
match_request_method => 'delete',
allow => $_puppet_admin_certs,
sort_order => 500,
path => "${confdir}/conf.d/auth.conf",
}
puppet_authorization::rule { 'puppetlabs jruby pool':
@binford2k
binford2k / Export
Last active March 20, 2024 18:00
Windows filesystem permission repairs
icacls c:windows /save win2k12_windows.txt /t /c
icacls c:progra~3 /save win2k12_programdata.txt /t /c
icacls c:users /save win2k12_users.txt /t /c
icacls c:progra~1 /save win2k12_programfiles.txt /t /c
icacls c:progra~2 /save win2k12_programfilesx86.txt /t /c
class profile::webserver {
class{'::apache': }
apache::vhost { "vhost.example.com":
port => '80',
docroot => '/var/www/vhost',
}
}
09:30 $ puppet apply test.pp
Notice: Scope(Class[main]): this is a
Notice: Scope(Class[main]): itsa b!
Notice: Scope(Class[main]): always the right answer
Notice: Compiled catalog for ganymede.local in environment production in 0.17 seconds
Notice: Applied catalog in 0.03 seconds

This will clear all Code Manager and FileSync caches so you can redeploy fresh.

systemctl stop pe-puppetserver

# filesync cache
rm -rf /opt/puppetlabs/server/data/puppetserver/filesync

# r10k cache
rm -rf /opt/puppetlabs/server/data/code-manager/git
root:!!:16786:0:99999:7:::
bin:*:16659:0:99999:7:::
daemon:*:16659:0:99999:7:::
adm:*:16659:0:99999:7:::
lp:*:16659:0:99999:7:::
sync:*:16659:0:99999:7:::
shutdown:*:16659:0:99999:7:::
halt:*:16659:0:99999:7:::
mail:*:16659:0:99999:7:::
operator:*:16659:0:99999:7:::
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
$versions = ['5.3.3', '4.9.0', '2.7.4', '3.6.2', '3.8.5' ]
# ...
if $versions {
$_versions = $versions.sort.reverse.join(', ')
$_packages = $versions.map |$version| {
"puppet:${version}"
}.join(' ')
Puppet::Parser::Functions.newfunction(:pt_env_facts, :doc => <<-EOS
This function exposes PT_* environment variables as a structured fact, $pt_vars
EOS
) do
variables = {}
ENV.each do |var, value|
if match = var.match(/^PT_(.*)$/)
variables[match] = value
end
end

An Introduction to Facter

Facter is Puppet’s cross-platform system profiling library. It discovers and reports per-node facts, which are available in your Puppet manifests as variables.

At the end of this course you will be able to:

  • describe the type of information stored in Facter.
  • demonstrate how to view the information stored in Facter.

To see the actual available facts (including plugins) and their values on any of your