Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## Function module Puppet::Parser::Functions newfunction(:currhost_containedin, :type => :rvalue) do |args| currhost = lookupvar('hostname') return args[0].include("#{currhost}") end end ## Manifest example class ssh_keys { # User keys @ssh_userkeys { "storage": privkeyname => "id_rsa", fromhosts => ["log2","universe"], dotsshpath => "/home/storage/.ssh"; } define ssh_userkeys( $dotsshpath, $privkeyname, $type = "rsa", $fromhosts ){ $copypriv = currhost_containedin($fromhosts) if $copypriv == $hostname { file { "privkey_${name}_${privkeyname}": owner => $name, group => $name, ensure => "file", path => "$dotsshpath/$privkeyname", mode => "0600", content => $privkey_contents, require => File[$dotsshpath, $authkeysfile]; } } } } ## Failure message root@foo:~# puppetd --test --ignorecache info: Retrieving facts err: Could not retrieve catalog: undefined method `include' for "log2":String at /etc/puppet/manifests/definitions/definitions.pp:177 on node foo.domain.tld warning: Not using cache on failed catalog
This paste will be private.
From the Design Piracy series on my blog: