Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
pass Resources to a define or unsetting notify
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Meier  
View profile  
 More options Mar 22 2008, 3:03 pm
From: Peter Meier <peter.me...@immerda.ch>
Date: Sat, 22 Mar 2008 20:03:40 +0100
Local: Sat, Mar 22 2008 3:03 pm
Subject: pass Resources to a define or unsetting notify
Hi

i'm trying to pass Resources (single or in an array) to a resource, so I
can pass this to a notify or require. However I have some problems, when
no resource should be passed. Maybe somebody can help me? thanks

define gentoo::etcconfd (
    $require = '',
    $notify = ''
){
    file { "/etc/conf.d/${name}":
        owner => "root",
        group => "0",
        mode  => 644,
        source => [
            "puppet://$server/dist/gentoo/etc_conf.d/${name}_${fqdn}",
            "puppet://$server/dist/gentoo/etc_conf.d/${name}_default",
            "puppet://$server/gentoo/etc_conf.d/${name}"
        ],
        require => $require,
        notify => $notify,
    }

}

#works not:
gentoo::etcconfd { foobar: }
#works:
gentoo::etcconfd { apache2: require => "Package[apache]", notify =>
"Service[apache]"}

#Error I get:
err: Could not create /etc/conf.d/foobar: Parameter require failed:
interning empty string

I also tried setting it to undef, which didn't change anything.

Or should I use a trick to pass the resource?

thanks for your help and greets pete


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashley Penney  
View profile  
 More options Mar 22 2008, 3:20 pm
From: "Ashley Penney" <apen...@gmail.com>
Date: Sat, 22 Mar 2008 15:20:31 -0400
Local: Sat, Mar 22 2008 3:20 pm
Subject: Re: [Puppet Users] pass Resources to a define or unsetting notify

I'm no expert, but why don't you try wrapping the require => $require
statments with an 'if $require', just to make sure it only tries to set it
if the variable exists.  That way if you don't pass a $require, it won't
exist and should work!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke Kanies  
View profile  
 More options Mar 22 2008, 4:35 pm
From: Luke Kanies <l...@madstop.com>
Date: Sat, 22 Mar 2008 15:35:56 -0500
Local: Sat, Mar 22 2008 4:35 pm
Subject: Re: [Puppet Users] pass Resources to a define or unsetting notify
On Mar 22, 2008, at 2:03 PM, Peter Meier wrote:

> Hi

> i'm trying to pass Resources (single or in an array) to a resource,  
> so I
> can pass this to a notify or require. However I have some problems,  
> when
> no resource should be passed. Maybe somebody can help me? thanks

> define gentoo::etcconfd (
>    $require = '',
>    $notify = ''
> ){

You don't need to declare these (in fact, you should be seeing a  
warning for them); all defined types automatically support all  
metaparameters.

Otherwise, follow the advice of the other poster: default to false,  
and test for the value before you go ahead and set it on the  
resource.  That won't work for metaparameters, because resources  
automatically acquire all metaparameters from the definition they're in.

--
A bore is a man who deprives you of solitude without providing you
with company. -- Gian Vincenzo Gravina
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Meier  
View profile  
 More options Mar 23 2008, 6:18 am
From: Peter Meier <peter.me...@immerda.ch>
Date: Sun, 23 Mar 2008 11:18:44 +0100
Local: Sun, Mar 23 2008 6:18 am
Subject: Re: [Puppet Users] Re: pass Resources to a define or unsetting notify
Hi

> You don't need to declare these (in fact, you should be seeing a  
> warning for them); all defined types automatically support all  
> metaparameters.

ah cool. Didn't know that. I tried to add this to the Language Tutorial:
http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial?action=dif...
I hope that this might be ok?! Otherwise please change/correct it.

> Otherwise, follow the advice of the other poster: default to false,  
> and test for the value before you go ahead and set it on the  
> resource.  That won't work for metaparameters, because resources  
> automatically acquire all metaparameters from the definition they're in.

this works now: :)

define gentoo::etcconfd (){
    file { "/etc/conf.d/${name}":
        owner => "root",
        group => "0",
        mode  => 644,
        source => [
            "puppet://$server/dist/gentoo/etc_conf.d/${name}_${fqdn}",
            "puppet://$server/dist/gentoo/etc_conf.d/${name}_default",
            "puppet://$server/gentoo/etc_conf.d/${name}"
        ],
    }
    if $require {
        File["/etc/conf.d/${name}"]{
            require => $require,
        }
    }
    if $notify {
        File["/etc/conf.d/${name}"]{
            notify => $notify,
        }
    }

}

thanks a lot!

greets pete


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Turnbull  
View profile  
 More options Mar 23 2008, 10:56 am
From: James Turnbull <ja...@lovedthanlost.net>
Date: Mon, 24 Mar 2008 01:56:06 +1100
Local: Sun, Mar 23 2008 10:56 am
Subject: Re: [Puppet Users] Re: pass Resources to a define or unsetting notify
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Meier wrote:

| Hi
|
|> You don't need to declare these (in fact, you should be seeing a
|> warning for them); all defined types automatically support all
|> metaparameters.
|
| ah cool. Didn't know that. I tried to add this to the Language Tutorial:
|
http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial?action=dif...
| I hope that this might be ok?! Otherwise please change/correct it.
|

Might want to include an example and a bit more information - the
Tutorial is designed as an introduction.

Regards

James Turnbull

- --
James Turnbull (ja...@lovedthanlost.net)
- --
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 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH5m+G9hTGvAxC30ARApNkAKCbYIYKB4cWK/KY1dWYybhyyiGnVQCgubsH
rDuxxxQrhEF7dor8MzMZwU8=
=P39y
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brice Figureau  
View profile  
 More options Mar 28 2008, 9:26 am
From: Brice Figureau <brice-pup...@daysofwonder.com>
Date: Fri, 28 Mar 2008 14:26:06 +0100
Local: Fri, Mar 28 2008 9:26 am
Subject: Re: [Puppet Users] Re: pass Resources to a define or unsetting notify
Hi,

What is not clear to me, is if the resources in the define section
inherits the metaparameters or if we have to "propagate" them by hand?

In other words, should I do:
ex:
define my_definition() {
        file {
                ...
        }
        exec {
                ...
        }

}

or
define my_definition() {
        file {
                ...
                require => $require
        }
        exec {
                ...
                require => $require
        }

}

It was my understanding that they fully propagate, but I just want to be
sure it's really the case.

Thanks for clarifying,
--
Brice Figureau <brice-pup...@daysofwonder.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke Kanies  
View profile  
 More options Mar 28 2008, 10:45 am
From: Luke Kanies <l...@madstop.com>
Date: Fri, 28 Mar 2008 09:45:30 -0500
Local: Fri, Mar 28 2008 10:45 am
Subject: Re: [Puppet Users] Re: pass Resources to a define or unsetting notify
On Mar 28, 2008, at 8:26 AM, Brice Figureau wrote:

This really is very easy to test:

define mptest {
     notify { "this is a $name test": }

}

mptest { yay: loglevel => warning }

Prints:

warning: this is a yay test

Notice the loglevel.

--
This book fills a much-needed gap. -- Moses Hadas
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »