Skip to content

Instantly share code, notes, and snippets.

View binford2k's full-sized avatar

Ben Ford binford2k

View GitHub Profile
require 'puppet'
Puppet.initialize_settings
def encrypt(data, destination)
certpath = Puppet.settings[:cacert]
keypath = Puppet.settings[:cakey]
destpath = "#{Puppet.settings[:signeddir]}/#{destination}.pem"
cert = OpenSSL::X509::Certificate.new(File.read(certpath))
11:01 $ rangefinder ~/Projects/puppet-remote_file/lib/puppet/type/remote_file.rb
[remote_file] is a _type_
==================================
Breaking changes to this file MAY impact these modules:
* papertrail-papertrail (https://github.com/papertrail/puppet-papertrail)
* opstree-snoopy (https://github.com/OpsTree/opstree-snoopy.git)
* pcfens-topbeat (https://github.com/pcfens/puppet-topbeat)
* poolski-packetbeat (https://github.com/poolski/puppet-packetbeat)
* pcfens-ca_cert (https://github.com/pcfens/puppet-ca_cert)
* dodevops-githubreleases (https://github.com/dodevops/puppet-githubreleases)
12:29 $ ./label_provider.rb
Object (label provider is incomplete for Puppet::Pops::Model::Factory)
12:29 $
notify { ['hello', 'there', 'trailing', 'comma', ]: }
define nginx::conf (
Optional[String] $source = undef,
Enum[
'reload','restart',
'configtest','upgrade',
] $service_action = 'upgrade',
) {
}
class cfg_kvm_libvirt::install {
package { 'libvirt':
ensure => latest,
}
user { 'virtmgr':
ensure => 'present',
comment => 'virt user',
forcelocal => true,
home => '/home/virtmgr',
@binford2k
binford2k / facter.rb
Created August 17, 2018 05:20
/usr/local/bin/facter
#! /usr/bin/env ruby
require 'json'
ENV['facter_cache'] ||= `/opt/puppetlabs/bin/facter --show-legacy --no-external-facts --json`
cache = JSON.parse(ENV['facter_cache']) rescue {}
value = ARGV.first.split('.').reduce(cache) do |collector, key|
break unless collector.keys.include? key
collector[key]
end
class first {
notify { 'first': }
}
class outside {
include floater # this class is uncontained, so it will "float" outside the graph
}
class floater {
notify { 'floater': }
puppet apply parse_order.pp
Notice: Compiled catalog for ganymede.corp.puppetlabs.net in environment production in 0.16 seconds
Notice: foo
Notice: /Stage[main]/Foo/Notify[foo]/message: defined 'message' as 'foo'
Notice: after the include
Notice: /Stage[main]/Main/Notify[after the include]/message: defined 'message' as 'after the include'
Notice: Applied catalog in 0.05 seconds
[root@ip-172-31-20-152 modules]# cat foo/manifests/params.pp
class foo::params {
$bar = 'baz'
}
[root@ip-172-31-20-152 modules]# cat foo/manifests/something.pp
class foo::something {
# this does NOT resolve up to $foo::bar because it has no parent class
notify { $bar: }
}