Stuart Cracraft
2013-Nov-15 18:30 UTC
[Puppet Users] running a program and returning the value
Hi, I want to run a command: /usr/bin/id someusername and then check that the output is equal to some variable. Is there a way to do this in puppet pattern language? Stuart -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/afc86717-2679-4af8-b205-da2d9025af62%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Stuart Cracraft
2013-Nov-15 19:36 UTC
[Puppet Users] Re: running a program and returning the value
Also, I want to see the return status code, besides the standard output from the program. Does Puppet not provide a way to get at either? On Friday, November 15, 2013 10:30:28 AM UTC-8, Stuart Cracraft wrote:> > Hi, > > I want to run a command: > > /usr/bin/id someusername > > and then check that the output is equal to some variable. > > Is there a way to do this in puppet pattern language? > > Stuart > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/1d9f81d2-b33c-43bb-abe1-089d6046a7a2%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Nov-15 21:55 UTC
[Puppet Users] Re: running a program and returning the value
On Friday, November 15, 2013 1:36:59 PM UTC-6, Stuart Cracraft wrote:> > > Also, I want to see the return status code, besides the standard output > from the program. > > Does Puppet not provide a way to get at either? > > On Friday, November 15, 2013 10:30:28 AM UTC-8, Stuart Cracraft wrote: > >> >> Hi, >> >> I want to run a command: >> >> /usr/bin/id someusername >> >> and then check that the output is equal to some variable. >> >For what purpose? Are you sure you''re not trying to duplicate User-management behavior that Puppet can do for you?> >> Is there a way to do this in puppet pattern language? >> >> >To probe the target node before applying any resources, so as to inform decisions about what resources should be declared for the node or what their properties should be, create and use custom facts. These can execute arbitrary commands and generally do anything Ruby can do to compute fact values. To probe the target node during the catalog application process (at which point it is too late to alter the catalog for that run), use a resource -- ether an Exec or a custom resource. Specifically for Execs, control whether the standard output is captured in Puppet''s log by twiddling the Exec''s ''logoutput'' parameter. Setting logoutput => true should cause the output to be logged whenever the Exec is synced. To inject your own mechanism for managing resources of an existing type, create a custom provider for that type. Overall, though, Puppet DSL is not a scripting language, and Puppet is not a script engine. If you want a general-purpose remote control or automated testing tool then there are other products that are better suited. Depending on your needs, it might make sense to use Puppet together with such a tool, or it might just be simplest to use one of those other tools exclusively. That''s not to say that Puppet *can''t* be made to do what you ask, but it might be more trouble than it''s worth. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/26d6970d-a0c3-46bd-a5ba-763dbf98b677%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Rich Burroughs
2013-Nov-17 03:24 UTC
Re: [Puppet Users] running a program and returning the value
Yeah I''m with John. I don''t know what your use case is, but if you want to make sure that user''s UID is set to a certain value, that''s a great task for Puppet''s user management. Manage the user in a manifest and set the UID, and Puppet will make sure it''s set to that value each time the agent runs. If it''s got the wrong UID somehow, Puppet will fix it. Rich On Friday, November 15, 2013, jcbollinger wrote:> > > On Friday, November 15, 2013 1:36:59 PM UTC-6, Stuart Cracraft wrote: >> >> >> Also, I want to see the return status code, besides the standard output >> from the program. >> >> Does Puppet not provide a way to get at either? >> >> On Friday, November 15, 2013 10:30:28 AM UTC-8, Stuart Cracraft wrote: >> >>> >>> Hi, >>> >>> I want to run a command: >>> >>> /usr/bin/id someusername >>> >>> and then check that the output is equal to some variable. >>> >> > > For what purpose? Are you sure you''re not trying to duplicate > User-management behavior that Puppet can do for you? > > > >> >>> Is there a way to do this in puppet pattern language? >>> >>> >> > > To probe the target node before applying any resources, so as to inform > decisions about what resources should be declared for the node or what > their properties should be, create and use custom facts. These can execute > arbitrary commands and generally do anything Ruby can do to compute fact > values. > > To probe the target node during the catalog application process (at which > point it is too late to alter the catalog for that run), use a resource -- > ether an Exec or a custom resource. Specifically for Execs, control > whether the standard output is captured in Puppet''s log by twiddling the > Exec''s ''logoutput'' parameter. Setting logoutput => true should cause the > output to be logged whenever the Exec is synced. > > To inject your own mechanism for managing resources of an existing type, > create a custom provider for that type. > > Overall, though, Puppet DSL is not a scripting language, and Puppet is not > a script engine. If you want a general-purpose remote control or automated > testing tool then there are other products that are better suited. > Depending on your needs, it might make sense to use Puppet together with > such a tool, or it might just be simplest to use one of those other tools > exclusively. That''s not to say that Puppet *can''t* be made to do what > you ask, but it might be more trouble than it''s worth. > > > John > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com <javascript:_e({}, > ''cvml'', ''puppet-users%2Bunsubscribe@googlegroups.com'');>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/26d6970d-a0c3-46bd-a5ba-763dbf98b677%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAPGcbtAHA%3DXt7vhqMLW%2Bu3FRsbELYW386b85dHzTJZt9d-JWCw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.