This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1] pry(main)> require 'puppet' | |
=> true | |
[2] pry(main)> Puppet::Type.type(:file).new({:ensure => 'file', :path => '/tmp/thing'}) | |
=> #<Puppet::Type::File:0x0000000474ef88 | |
@clients={}, | |
@name_var_cache=:path, | |
@original_parameters={:ensure=>"file"}, | |
@parameters= | |
{:path=>#<Puppet::Type::File::ParameterPath:0x0000000474a758 @resource=#<Puppet::Type::File:0x0000000474ef88 ...>, @value="/tmp/thing">, | |
:provider=>#<Puppet::Type::File::ParameterProvider:0x0000000474a078 @resource=#<Puppet::Type::File:0x0000000474ef88 ...>, @value=:posix>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@centos:~/repos # puppet apply <<'PP' | |
> $_regex_array = [ | |
> '\d', | |
> '\w', | |
> '\d+', | |
> ] | |
> if '1a1234' =~ $_regex_array.join('') { | |
> notice('hi') | |
> } | |
> PP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@puppet2017 ~]# puppet resource node_group 'PE Master' provider=https --debug | |
Debug: Runtime environment: puppet_version=4.9.4, ruby_version=2.1.9, run_mode=user, default_encoding=UTF-8 | |
Debug: Failed to load library 'puppetclassify' for feature 'puppetclassify' | |
Debug: Puppet::Type::Node_group::ProviderPuppetclassify: feature puppetclassify is missing | |
Debug: Loaded state in 0.15 seconds | |
Debug: Loaded transaction store file in 0.00 seconds | |
Debug: Prefetching https resources for node_group | |
Debug: classifier_url: https://puppet2017.1.1.puppetlabs.vm:4433/classifier-api | |
Debug: Using SSL authentication | |
Debug: Finishing transaction 28162460 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Look for puppetfile.yaml and then puppetfile.json | |
begin | |
require 'yaml' | |
puppetfile = YAML.load_file('./puppetfile.yaml') | |
rescue | |
begin | |
require 'json' | |
puppetfile = JSON.parse(File.read('./puppetfile.json')) | |
rescue | |
fail 'Could not find file "puppetfile.yaml" or "puppetfile.json"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@puppet2017 /etc/puppetlabs/code/modules/hocon_funk]# facter dmi | |
{ | |
bios => { | |
release_date => "12/01/2006", | |
vendor => "innotek GmbH", | |
version => "VirtualBox" | |
}, | |
board => { | |
manufacturer => "Oracle Corporation", | |
product => "VirtualBox", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TOKEN='0ZJ40A1YvorJu20ZDT6qGvDlLsRbWC7nEdTxRpwrV7ro' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@puppet2017 ~]# cat /tmp/test.pp | |
$epptemplate = @(EPP/L) | |
<%- | $nodes | -%> | |
My nodes: | |
<% $nodes.each |$n| { -%> | |
Hostname: <%= $n[0] %> | |
IP: <%= $n[1] %> | |
<% } -%> | |
| EPP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plain text | |
concat_file { '/tmp/test.txt': | |
ensure => present, | |
tag => 'plain_concat', | |
format => 'plain', | |
} | |
concat_fragment { 'header plain': | |
content => '{ "one": "foo" }', | |
order => '01', | |
target => '/tmp/test.txt', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'puppet/face/resource' | |
Facter.add(:homedirs) do | |
setcode do | |
Puppet::Face[:resource, '0.0.1'].search("user").map { |u| Hash[u.title, u[:home]] }.reduce({}, :merge) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Noop | |
[root@puppet2017 ~]# puppet apply /tmp/test.pp --noop | |
Notice: Compiled catalog for puppet2017.1.1.puppetlabs.vm in environment production in 0.08 seconds | |
Notice: /Stage[main]/Main/Package[tgm4883]/ensure: current_value purged, should be lalalalalalala (noop) | |
Notice: Class[Main]: Would have triggered 'refresh' from 1 events | |
Notice: Stage[main]: Would have triggered 'refresh' from 1 events | |
Notice: Applied catalog in 0.37 seconds | |