Puppet's Search function

63 views
Skip to first unread message

Robb Wagoner

unread,
Feb 23, 2009, 12:29:53 PM2/23/09
to puppet...@googlegroups.com
Hello all,
I have read through the sparse documentation on the Search (intentionally capitalized to differentiate from the verb) function as well as searched the group list (and mail archives) with little success to finding an answer. It is my understanding that I want to use the Search function to achieve my goal.

I would like to know:
a) is my understanding about the purpose of this function incorrect?
b) the recommended way to accomplish making variables defined in classes available to other classes, dynamically (see below as an example).

Using a contrived example, I have a series of classes with site-specific settings & variables:

site::office
site::datacenter
etc.

In each of these classes I have some site-specific variables defined that I want to be able to reference in other classes.

manifests/site.pp:
$site_name = "office"

site/manifests/office.pp:
class site::office inherits site::common {
  $dns1 = "1.2.3.4"
  $dns2 = "2.3.4.5"
  $search = "$site_name.local"
}

bind/manifests/dns.pp:
class dns::client inherits dns::common {
  search "site::$site_name"

  file { "/etc/resolv.conf" :
    content => "search $search\n nameserver $dns1\nnameserver $dns2\n"
  }

}

I get error that the variables, $search, $dns1, et cetera are unknown.

Thank you and regards,
Robb

Bruce Richardson

unread,
Feb 23, 2009, 12:40:50 PM2/23/09
to puppet...@googlegroups.com
On Mon, Feb 23, 2009 at 09:29:53AM -0800, Robb Wagoner wrote:
> I would like to know:
> a) is my understanding about the purpose of this function incorrect?
> b) the recommended way to accomplish making variables defined in classes
> available to other classes, dynamically (see below as an example).

Your understanding is incorrect. I came up against this lack of
documentation the other day so went looking to see what the code did; it
turns out that it adds nested classes and defines from other classes
into the local class but not variables. You'll find the relevant code
in parser.rb and scope.rb.

--
Bruce

Explota!: miles de lemmings no pueden estar equivocados.

Peter Meier

unread,
Feb 23, 2009, 12:56:05 PM2/23/09
to puppet...@googlegroups.com
Hi

> On Mon, Feb 23, 2009 at 09:29:53AM -0800, Robb Wagoner wrote:
>> I would like to know:
>> a) is my understanding about the purpose of this function incorrect?
>> b) the recommended way to accomplish making variables defined in classes
>> available to other classes, dynamically (see below as an example).
>
> Your understanding is incorrect. I came up against this lack of
> documentation the other day so went looking to see what the code did; it
> turns out that it adds nested classes and defines from other classes
> into the local class but not variables. You'll find the relevant code
> in parser.rb and scope.rb.

would be nice if you could add this documentation to the wiki,
because... eh it's a wiki!

thanks and cheers

pete

Robb

unread,
Feb 23, 2009, 1:09:34 PM2/23/09
to Puppet Users
Bruce,
Thank you for the explanation. I will review the parser.rb and
scope.rb to familiarize myself with the code.

Bruce Richardson

unread,
Feb 24, 2009, 4:44:30 AM2/24/09
to puppet...@googlegroups.com
On Mon, Feb 23, 2009 at 06:56:05PM +0100, Peter Meier wrote:
>
> would be nice if you could add this documentation to the wiki,
> because... eh it's a wiki!

The functions reference page is autogenerated. What is the source, if I
am to update it?

--
Bruce

What would Edward Woodward do?

James Turnbull

unread,
Feb 24, 2009, 5:14:18 AM2/24/09
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bruce Richardson wrote:
> On Mon, Feb 23, 2009 at 06:56:05PM +0100, Peter Meier wrote:
>> would be nice if you could add this documentation to the wiki,
>> because... eh it's a wiki!
>
> The functions reference page is autogenerated. What is the source, if I
> am to update it?
>

Log a ticket in Redmine with your updates.

Thanks

James Turnbull

- --
Author of:
* Pulling Strings with Puppet
(http://www.amazon.com/gp/product/1590599780/)
* Pro Nagios 2.0
(http://www.amazon.com/gp/product/1590596099/)
* Hardening Linux
(http://www.amazon.com/gp/product/1590594444/)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJo8h59hTGvAxC30ARAk59AKCl8vmZK6yzKw5XgrjBry/8g4MeNACfYTBm
Y3YZIy30BmIv9XpydMgJPiE=
=M+vB
-----END PGP SIGNATURE-----

Peter Meier

unread,
Feb 24, 2009, 5:26:53 AM2/24/09
to puppet...@googlegroups.com
Hi

>> would be nice if you could add this documentation to the wiki,
>> because... eh it's a wiki!
>
> The functions reference page is autogenerated. What is the source, if I
> am to update it?

the code.

However for more extended example it might be nice to create wiki page.
But if it's just a few lines, I think James is fine with code patches.

cheers pete

Bruce Richardson

unread,
Feb 24, 2009, 5:28:11 AM2/24/09
to puppet...@googlegroups.com
On Tue, Feb 24, 2009 at 09:14:18PM +1100, James Turnbull wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Bruce Richardson wrote:
> > On Mon, Feb 23, 2009 at 06:56:05PM +0100, Peter Meier wrote:
> >> would be nice if you could add this documentation to the wiki,
> >> because... eh it's a wiki!
> >
> > The functions reference page is autogenerated. What is the source, if I
> > am to update it?
> >
>
> Log a ticket in Redmine with your updates.

OK, having already registered on the wiki, I just tried to register on
redmine and it's returning an error.


--
Bruce

Hierophant: someone who remembers, when you are on the way down,
everything you did to them on the way up.

Bruce Richardson

unread,
Feb 24, 2009, 6:14:09 AM2/24/09
to puppet...@googlegroups.com

I'll submit a patch but it sounds like it might be a good idea to change
the template for the function references page to include a link to
/track/wiki/Function_Usage_Examples#functionname . I'd happily populate
that page and then bug people to correct my mistakes and fill in the
gaps. If nobody can suggest a better name, I'll take some time to day
to create that page in the hope that the links will appear later.

--
Bruce

I see a mouse. Where? There, on the stair. And its clumsy wooden
footwear makes it easy to trap and kill. -- Harry Hill

Reply all
Reply to author
Forward
0 new messages