Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am eshamow on github.
  • I am eshamow (https://keybase.io/eshamow) on keybase.
  • I have a public key ASC0qrMF5Id_Y1xnAQnlkuTXuldv1UWDfAM_Y9p_wwBPggo

To claim this, I am signing this object:

....................../´¯/)
....................,/¯../
.................../..../
............./´¯/'...'/´¯¯`·¸
........../'/.../..../......./¨¯\
........('(...´...´.... ¯~/'...')
.........\.................'...../
..........''...\.......... _.·´
............\..............(
..............\.............\...
#!/usr/bin/ruby
require 'rubygems'
require 'hiera'
#require 'puppet'
# Load the "facts" for the host to export settings for.
if ARGV.length != 1
puts "Usage: #{File.basename($PROGRAM_NAME)} /path/to/host-facts.yaml"
exit
============
Last updated: Wed Aug 29 16:15:04 2012
Stack: openais
Current DC: pe-debian6 - partition with quorum
Version: 1.0.9-74392a28b7f31d7ddc86689598bd23114f58978b
2 Nodes configured, 2 expected votes
4 Resources configured.
============
Online: [ pe-debian6 pe-debian6-2 ]
Aug 29 14:56:13 pe-debian6 crm_resource: [8641]: info: Invoked: crm_resource -P
Waiting for 1 replies from the CRMd.
Aug 29 14:56:13 pe-debian6 corosync[3753]: [TOTEM ] mcasted message added to pending queue
Aug 29 14:56:13 pe-debian6 corosync[3753]: [TOTEM ] Delivering 249 to 24a
Aug 29 14:56:13 pe-debian6 corosync[3753]: [TOTEM ] Delivering MCAST message with seq 24a to pending delivery queue
Aug 29 14:56:13 pe-debian6 corosync[3753]: [TOTEM ] Received ringid(192.168.8.129:76) seq 24a
Aug 29 14:56:13 pe-debian6 crmd: [3770]: debug: attrd_update: Sent update: probe_complete=false for localhost
Aug 29 14:56:13 pe-debian6 attrd: [3768]: debug: attrd_local_callback: update message from crmd: probe_complete=false
Aug 29 14:56:13 pe-debian6 attrd: [3768]: debug: attrd_local_callback: Supplied: false, Current: true, Stored: true
Aug 29 14:56:13 pe-debian6 attrd: [3768]: debug: attrd_local_callback: New value of probe_complete is false
Aug 29 14:54:30 pe-debian6 cibadmin: [8553]: info: Invoked: cibadmin -Ql
node pe-debian6
node pe-debian6-2
primitive ca_data ocf:pacemaker:ppdata \
op monitor interval="30s" \
meta target-role="Master" resource-stickiness="100"
primitive ca_service lsb:pe-httpd \
op start interval="0" timeout="30s" on-fail="restart" \
op monitor interval="10s" timeout="30s" \
meta resource-stickiness="100"
crm(live)# status
============
Last updated: Tue Aug 28 17:09:59 2012
Stack: openais
Current DC: pe-debian6 - partition with quorum
Version: 1.0.9-74392a28b7f31d7ddc86689598bd23114f58978b
2 Nodes configured, 2 expected votes
4 Resources configured.
============
root@pe-debian6:/etc/puppetlabs/puppet/modules/corosync# FACTER_ca_master=pe-debian6.localdomain puppet agent -t
info: Retrieving plugin
info: Loading facts in /etc/puppetlabs/puppet/modules/haca/lib/facter/ca_master.rb
info: Loading facts in /opt/puppet/share/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
info: Loading facts in /opt/puppet/share/puppet/modules/stdlib/lib/facter/root_home.rb
info: Loading facts in /opt/puppet/share/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/ca_master.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/facter_dot_d.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/root_home.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/puppet_vardir.rb
$ librarian-puppet install
/Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/librarian-puppet-0.9.3/lib/librarian/puppet/lockfile/parser.rb:41:in `parse': Expected DEPENDENCIES topic! (StandardError)
from /Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/librarian-puppet-0.9.3/vendor/librarian/lib/librarian/lockfile.rb:21:in `load'
from /Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/librarian-puppet-0.9.3/vendor/librarian/lib/librarian/action/resolve.rb:31:in `run'
from /Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/librarian-puppet-0.9.3/vendor/librarian/lib/librarian/cli.rb:161:in `resolve!'
from /Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/librarian-puppet-0.9.3/lib/librarian/puppet/cli.rb:59:in `install'
from /Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/thor-0.16.0/lib/thor/task.rb:27:in `send'
from /Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
from /Users/eric/.rvm/gems/ruby-1.8.7-p370/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
from /Users/eric/.rvm/gems/ruby-1.8.7-
This is actually a pretty common modeling problem in Puppet.
I just wrote a function called ensure_resource that is intended to solve this problem.
https://github.com/bodepd/puppet-ensure_resource
The function allows you to ensure that a resource should exist in the catalog.
If the exact resource already exists in the catalog (meaning that it has the exact type, title, and specified parameters), it will not create the resource. Otherwise it will create the resource which could result in a duplicate resource definition if the resource already existed but had non-matching parameters.