[Puppet Users] Re: new to puppet. how to add condition in a class?

2009-10-19 Thread william Famy
2009/10/13 Teyo Tyree 

>
> Hey William,
>
> Welcome to Puppet.
>
_
[wf:]
thanks


>
> On Mon, Oct 12, 2009 at 2:01 AM, william Famy 
> wrote:
> > Hi.
> >
> > II am trying puppet after cfengine and I am looking for a method to use a
> > class if a file exist.
>
> One way to express this is to write a custom fact to test whether or
> not a file is on the client system.  Shouldn't be hard to follow the
> custom fact documentation.
>
> http://reductivelabs.com/trac/puppet/wiki/AddingFacts
>
> Then you can simply wrap a conditional around the fact you create.
>
__
[wf:]

Ok i create a small facter to test if the file is present

in /usr/lib/ruby/vendor_ruby/facter/
i use debian lenny
i create a ztestapache.rb file from selinux one

puppetmaster:/usr/lib/ruby/vendor_ruby/facter# cat ztestapache.rb
# Fact for SElinux
# Written by immerda admin team (admin(at)immerda.ch)

Facter.add("ztestapache") do
setcode do
result = "false"
if FileTest.exists?("/etc/puppet/install/apache")
result = "true"
end
result
end
end


so i the file /etc/puppet/install/apache is present i can ask puppet to
install apache2

I have to create the puppet class on my puppetmaster.

I will tell you as soon as possible.




>
> if $yourfact {
>  include yourclass
> }
>
> [...]
>
> So you can use the pattern above, but I bet there is a better way to
> model you configuration.  What is you use case?  Ignore Puppet and
> CFengine for a moment and describe the problem.  Often times there are
> simpler more maintainable patterns of expression that will yield the
> same configuration.
>
_
[wf:]

It is easy for me to deploy config on clients computer.
Exemple. I install 20 server on differents place and i allow peaple to add,
start programme like samba

The person want to add apache. He just have to connect the web interface and
ask for samba. the web interface create an empty file
/etc/puppet/install/samba and puppet do the job to install a working samba
from the puppet master. SO I do not have to manage my puppetmaster fqdn to
add samba and every one is happy.

>
> >
> >
> > thanks for your help.
> >
> > regards
> >
> > >
> >
>
> Cheers,
> Teyo
>
>
>
> --
> Teyo Tyree :: www.reductivelabs.com :: +1.615.275.5066
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~--~~~~--~~--~--~---



[Puppet Users] Re: new to puppet. how to add condition in a class?

2009-10-13 Thread Teyo Tyree

Hey William,

Welcome to Puppet.

On Mon, Oct 12, 2009 at 2:01 AM, william Famy  wrote:
> Hi.
>
> II am trying puppet after cfengine and I am looking for a method to use a
> class if a file exist.

One way to express this is to write a custom fact to test whether or
not a file is on the client system.  Shouldn't be hard to follow the
custom fact documentation.

http://reductivelabs.com/trac/puppet/wiki/AddingFacts

Then you can simply wrap a conditional around the fact you create.

if $yourfact {
  include yourclass
}

>
> exemple
>
> I have a condition class.
> I have to create on the server the condition class but i do not want to have
> it execute on every client. It is not easy for me to set on the server the
> condition to execute the class.
>
> I prefer runing class on my client if thereis a file exemple if the file
> /etc/mypuppet/condition is present execute the condition class.
>
> Is it possible?
> How can i do it?

So you can use the pattern above, but I bet there is a better way to
model you configuration.  What is you use case?  Ignore Puppet and
CFengine for a moment and describe the problem.  Often times there are
simpler more maintainable patterns of expression that will yield the
same configuration.

>
>
> thanks for your help.
>
> regards
>
> >
>

Cheers,
Teyo



-- 
Teyo Tyree :: www.reductivelabs.com :: +1.615.275.5066

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~--~~~~--~~--~--~---



[Puppet Users] Re: new to puppet. how to add condition in a class?

2009-10-13 Thread Allan Marcus

there are a number of ways to determine if a class should be applied  
to a client. If you gave us an example of the actual condition, not  
just an abstract, we might be able to provide better ideas for you.

---
Thanks,

Allan Marcus
505-667-5666



On Oct 12, 2009, at 3:01 AM, william Famy wrote:

> Hi.
>
> II am trying puppet after cfengine and I am looking for a method to  
> use a class if a file exist.
>
> exemple
>
> I have a condition class.
> I have to create on the server the condition class but i do not want  
> to have it execute on every client. It is not easy for me to set on  
> the server the condition to execute the class.
>
> I prefer runing class on my client if thereis a file exemple if the  
> file /etc/mypuppet/condition is present execute the condition class.
>
> Is it possible?
> How can i do it?
>
>
> thanks for your help.
>
> regards
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~--~~~~--~~--~--~---



[Puppet Users] Re: new to puppet. how to add condition in a class?

2009-10-13 Thread Trevor Vaughan

Just remember not to wrap define declarations in 'if' or 'case' statements.

It blows up spectacularly.

Trevor

On Tue, Oct 13, 2009 at 00:55, Andrew Shafer  wrote:
>
> You can technically do this with a custom fact as suggested.
>
> if $myfact {
>    include specialsauce
> }
>
> The rational behind why you would want to avoid this in general is
> simple, favor specificity.
>
> Machines shouldn't have a file that then decides how something else
> gets configured, you should tell machines what files to have.
>
> Conditional statements provide for necessary flexibility, but they
> also add complexity.
>
> We try to avoid situations where we have to look on a system to know
> how it is configured.
>
> Find a balance that works for you.
>
> Make sense?
>
>
>
> On Mon, Oct 12, 2009 at 3:48 PM, Matthias Saou
> 
> wrote:
>>
>> william Famy  wrote:
>>
>>> I prefer runing class on my client if thereis a file exemple if the
>>> file /etc/mypuppet/condition is present execute the condition class.
>>
>> If you want to do this, you'll likely have to create a simple facter
>> fact for your clients so that the puppetmaster receives "true" if this
>> file exists or "false" otherwise.
>>
>> But from my puppet experience, you seem to be taking the problem the
>> opposite way from the usual way. It's much more common to decide if a
>> class is to be included or not based on the existing facts (hostname,
>> fqdn etc.), and from the puppetmaster.
>>
>> Matthias
>>
>> >
>>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~--~~~~--~~--~--~---



[Puppet Users] Re: new to puppet. how to add condition in a class?

2009-10-12 Thread Andrew Shafer

You can technically do this with a custom fact as suggested.

if $myfact {
include specialsauce
}

The rational behind why you would want to avoid this in general is
simple, favor specificity.

Machines shouldn't have a file that then decides how something else
gets configured, you should tell machines what files to have.

Conditional statements provide for necessary flexibility, but they
also add complexity.

We try to avoid situations where we have to look on a system to know
how it is configured.

Find a balance that works for you.

Make sense?



On Mon, Oct 12, 2009 at 3:48 PM, Matthias Saou

wrote:
>
> william Famy  wrote:
>
>> I prefer runing class on my client if thereis a file exemple if the
>> file /etc/mypuppet/condition is present execute the condition class.
>
> If you want to do this, you'll likely have to create a simple facter
> fact for your clients so that the puppetmaster receives "true" if this
> file exists or "false" otherwise.
>
> But from my puppet experience, you seem to be taking the problem the
> opposite way from the usual way. It's much more common to decide if a
> class is to be included or not based on the existing facts (hostname,
> fqdn etc.), and from the puppetmaster.
>
> Matthias
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~--~~~~--~~--~--~---



[Puppet Users] Re: new to puppet. how to add condition in a class?

2009-10-12 Thread Matthias Saou

william Famy  wrote:

> I prefer runing class on my client if thereis a file exemple if the
> file /etc/mypuppet/condition is present execute the condition class.

If you want to do this, you'll likely have to create a simple facter
fact for your clients so that the puppetmaster receives "true" if this
file exists or "false" otherwise.

But from my puppet experience, you seem to be taking the problem the
opposite way from the usual way. It's much more common to decide if a
class is to be included or not based on the existing facts (hostname,
fqdn etc.), and from the puppetmaster.

Matthias

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~--~~~~--~~--~--~---