hyzhang
2011-Jun-08 18:01 UTC
[Puppet Users] how do I tell puppet do nothing if the condition is true
Hi, I have a piece of puppet code. I want puppet do nothing if it is true. How do I do that? Of course this code would not code. exec { ''runlevel'': command => $is_virtual ? { ''false'' => "/bin/sed -i ''s/id:3:initdefault:/id: 5:initdefault:/'' /etc/inittab", ''true'' => ''tell puppet do nothing'', }, } -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nigel Kersten
2011-Jun-08 18:17 UTC
Re: [Puppet Users] how do I tell puppet do nothing if the condition is true
On Wed, Jun 8, 2011 at 11:01 AM, hyzhang <hyzhang@jcvi.org> wrote:> Hi, > > I have a piece of puppet code. I want puppet do nothing if it is true. > How do I do that? Of course this code would not code. > > exec { ''runlevel'': > command => $is_virtual ? { > ''false'' => "/bin/sed -i ''s/id:3:initdefault:/id: > 5:initdefault:/'' /etc/inittab", > ''true'' => ''tell puppet do nothing'', > }, > } >Move the conditional outside the resource. It''s much much easier to read. if $is_virtual == "false" { # put your exec resource here }> > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- Nigel Kersten Product, Puppet Labs @nigelkersten -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Patrick
2011-Jun-08 19:28 UTC
Re: [Puppet Users] how do I tell puppet do nothing if the condition is true
On Jun 8, 2011, at 11:01 AM, hyzhang wrote:> Hi, > > I have a piece of puppet code. I want puppet do nothing if it is true. > How do I do that? Of course this code would not code. > > exec { ''runlevel'': > command => $is_virtual ? { > ''false'' => "/bin/sed -i ''s/id:3:initdefault:/id: > 5:initdefault:/'' /etc/inittab", > ''true'' => ''tell puppet do nothing'', > }, > }Also, so it doesn''t run every time, consider putting a "grep whatever" as a run condition. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
hyzhang
2011-Jun-08 20:38 UTC
[Puppet Users] Re: how do I tell puppet do nothing if the condition is true
Thank you all. That works! -Haiyan On Jun 8, 3:28 pm, Patrick <kc7...@gmail.com> wrote:> On Jun 8, 2011, at 11:01 AM, hyzhang wrote: > > > Hi, > > > I have a piece of puppet code. I want puppet do nothing if it is true. > > How do I do that? Of course this code would not code. > > > exec { ''runlevel'': > > command => $is_virtual ? { > > ''false'' => "/bin/sed -i ''s/id:3:initdefault:/id: > > 5:initdefault:/'' /etc/inittab", > > ''true'' => ''tell puppet do nothing'', > > }, > > } > > Also, so it doesn''t run every time, consider putting a "grep whatever" as a run condition.-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.