Hi, Is there some way to have an exec run only if you pass a tag on the command line? For example: class fubar { exec { ''reboot-system'': refreshonly => true, command => ''/usr/bin/reboot'', subscribe => Class["dummy"] } } As I would expect, this throws an error the it can''t find the dummy class. Any suggestions on how I could accomplish this? ...dave -- 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.
On Wed, Nov 30, 2011 at 7:41 PM, Dave Alden <dave@alden.name> wrote:> Hi, > Is there some way to have an exec run only if you pass a tag on the command line? For example: > > > class fubar { > exec { ''reboot-system'': > refreshonly => true, > command => ''/usr/bin/reboot'', > subscribe => Class["dummy"] > } > } > > > As I would expect, this throws an error the it can''t find the dummy class. Any suggestions on how I could accomplish this?You can use facter to conditionally do this. Basically any environment variable starting with FACTER_ will become a puppet fact. FACTER_reboot=true puppet agent -t class fubar { if $reboot { exec { ... } } } Thanks, Nan -- 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.
On Nov 30, 2011, at 8:04 PM, Nan Liu wrote:> On Wed, Nov 30, 2011 at 7:41 PM, Dave Alden <dave@alden.name> wrote: >> Is there some way to have an exec run only if you pass a tag on the command line? For example: >> >> class fubar { >> exec { ''reboot-system'': >> refreshonly => true, >> command => ''/usr/bin/reboot'', >> subscribe => Class["dummy"] >> } >> } >> >> As I would expect, this throws an error the it can''t find the dummy class. Any suggestions on how I could accomplish this? > > You can use facter to conditionally do this. Basically any environment > variable starting with FACTER_ will become a puppet fact. > > FACTER_reboot=true puppet agent -t > class fubar { > if $reboot { > exec { > ... > } > } > }But that wouldn''t work with puppet kick, right? I want to be able to have a host reboot another host. :-) -- 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.
Kristof Willaert
2011-Dec-03 15:24 UTC
Re: [SPAM] Re: [Puppet Users] how to restrict an exec?
[snip] But that wouldn''t work with puppet kick, right? I want to be able to have> a host reboot another host. :-)That looks to me more like an orchestration issue, which is probably better solved by a tool like mcollective, func, rundeck, ... You are not changing state here, merely executing a "procedure". Kind regards, kristof -- 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.