Sachin Nikam
2013-Dec-09 03:31 UTC
[Puppet Users] puppet apply manifest command line parameters
I am newbie to puppet(versin 2.7) and came up with a manifest that contains some "exec" tasks. when I invoke the puppet apply <manifest>, I want to pass in some parameters specific to my application. How do I do that? I searched the online documentation but couldn''t find any examples. Regards Sachin -- 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/dcc8b086-e425-4f64-b86e-4b5e30bb3104%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jake Lundberg
2013-Dec-09 19:46 UTC
[Puppet Users] Re: puppet apply manifest command line parameters
I suppose it depends on how you structure your manifest. We typically apply a manifest to a particular node when testing new manifests. So something like: site.pp: node default { $param1 = "value1" $param2 = "value2" include exec_class } /etc/puppet/modules/exec_class/manifests/init.pp class exec_class ( $param1, $param2) { exec { "do something" : command => "/usr/local/bin/exec_something.sh" } } # puppet apply --modulepath=/etc/puppet/modules site.pp I also think you can pass parameters via facter: http://stackoverflow.com/questions/15901850/pass-variable-to-puppet-on-commandline On Sunday, December 8, 2013 7:31:27 PM UTC-8, Sachin Nikam wrote:> > I am newbie to puppet(versin 2.7) and came up with a manifest that > contains some "exec" tasks. when I invoke the puppet apply <manifest>, I > want to pass in some parameters specific to my application. How do I do > that? I searched the online documentation but couldn''t find any examples. > Regards > Sachin >-- 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/36932f82-1f68-42a9-b081-9b8fbd0ffb59%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jake Lundberg
2013-Dec-09 19:48 UTC
[Puppet Users] Re: puppet apply manifest command line parameters
Oops, that should probably read: exec { "do something" : command => "/usr/local/bin/exec_something.sh ${param1} ${param2}" } On Monday, December 9, 2013 11:46:17 AM UTC-8, Jake Lundberg wrote:> > I suppose it depends on how you structure your manifest. We typically > apply a manifest to a particular node when testing new manifests. So > something like: > > site.pp: > node default { > $param1 = "value1" > $param2 = "value2" > > include exec_class > } > > /etc/puppet/modules/exec_class/manifests/init.pp > class exec_class ( $param1, $param2) { > > exec { "do something" : > command => "/usr/local/bin/exec_something.sh" > } > } > > # puppet apply --modulepath=/etc/puppet/modules site.pp > > I also think you can pass parameters via facter: > http://stackoverflow.com/questions/15901850/pass-variable-to-puppet-on-commandline > > On Sunday, December 8, 2013 7:31:27 PM UTC-8, Sachin Nikam wrote: >> >> I am newbie to puppet(versin 2.7) and came up with a manifest that >> contains some "exec" tasks. when I invoke the puppet apply <manifest>, I >> want to pass in some parameters specific to my application. How do I do >> that? I searched the online documentation but couldn''t find any examples. >> Regards >> Sachin >> >-- 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/81157a24-fa6e-46fa-ac71-4a4474a5ab55%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Sachin Nikam
2013-Dec-09 20:50 UTC
[Puppet Users] Re: puppet apply manifest command line parameters
Jake, I want to do something like this... # puppet apply --modulepath=/etc/puppet/modules site.pp "somevalue1" "somevalue2" is this possible? Regards Sachin On Monday, 9 December 2013 11:48:16 UTC-8, Jake Lundberg wrote:> > Oops, that should probably read: > > exec { "do something" : > command => "/usr/local/bin/exec_something.sh ${param1} ${param2}" > } > > On Monday, December 9, 2013 11:46:17 AM UTC-8, Jake Lundberg wrote: >> >> I suppose it depends on how you structure your manifest. We typically >> apply a manifest to a particular node when testing new manifests. So >> something like: >> >> site.pp: >> node default { >> $param1 = "value1" >> $param2 = "value2" >> >> include exec_class >> } >> >> /etc/puppet/modules/exec_class/manifests/init.pp >> class exec_class ( $param1, $param2) { >> >> exec { "do something" : >> command => "/usr/local/bin/exec_something.sh" >> } >> } >> >> # puppet apply --modulepath=/etc/puppet/modules site.pp >> >> I also think you can pass parameters via facter: >> http://stackoverflow.com/questions/15901850/pass-variable-to-puppet-on-commandline >> >> On Sunday, December 8, 2013 7:31:27 PM UTC-8, Sachin Nikam wrote: >>> >>> I am newbie to puppet(versin 2.7) and came up with a manifest that >>> contains some "exec" tasks. when I invoke the puppet apply <manifest>, I >>> want to pass in some parameters specific to my application. How do I do >>> that? I searched the online documentation but couldn''t find any examples. >>> Regards >>> Sachin >>> >>-- 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/1cd00344-976a-48fd-a466-47873b2b8db4%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jake Lundberg
2013-Dec-09 21:29 UTC
[Puppet Users] Re: puppet apply manifest command line parameters
No, not like that. You could create your own custom fact and use that via command line. See: http://www.practicalclouds.com/content/guide/converting-user-data-arguments-facts. It''s not a perfect example, but does have some logic for parsing arguments. As you''re a self proclaimed newbie, this may take longer than you wish. Another option is you can wrap creating your manifest (site.pp or imports) in a script, but that''s probably not the ideal solution. What are you trying to do? Arbitrary remote execution of commands? If so, Puppet might not be the best platform. Consider something like Fabric/Capistrano, Ansible or Salt Stack (or just plain Bash). On Monday, December 9, 2013 12:50:44 PM UTC-8, Sachin Nikam wrote:> > Jake, > I want to do something like this... > # puppet apply --modulepath=/etc/puppet/modules site.pp "somevalue1" > "somevalue2" > > is this possible? > Regards > Sachin > > On Monday, 9 December 2013 11:48:16 UTC-8, Jake Lundberg wrote: >> >> Oops, that should probably read: >> >> exec { "do something" : >> command => "/usr/local/bin/exec_something.sh ${param1} ${param2}" >> } >> >> On Monday, December 9, 2013 11:46:17 AM UTC-8, Jake Lundberg wrote: >>> >>> I suppose it depends on how you structure your manifest. We typically >>> apply a manifest to a particular node when testing new manifests. So >>> something like: >>> >>> site.pp: >>> node default { >>> $param1 = "value1" >>> $param2 = "value2" >>> >>> include exec_class >>> } >>> >>> /etc/puppet/modules/exec_class/manifests/init.pp >>> class exec_class ( $param1, $param2) { >>> >>> exec { "do something" : >>> command => "/usr/local/bin/exec_something.sh" >>> } >>> } >>> >>> # puppet apply --modulepath=/etc/puppet/modules site.pp >>> >>> I also think you can pass parameters via facter: >>> http://stackoverflow.com/questions/15901850/pass-variable-to-puppet-on-commandline >>> >>> On Sunday, December 8, 2013 7:31:27 PM UTC-8, Sachin Nikam wrote: >>>> >>>> I am newbie to puppet(versin 2.7) and came up with a manifest that >>>> contains some "exec" tasks. when I invoke the puppet apply <manifest>, I >>>> want to pass in some parameters specific to my application. How do I do >>>> that? I searched the online documentation but couldn''t find any examples. >>>> Regards >>>> Sachin >>>> >>>-- 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/422ae7c4-3dd0-4035-b93f-6935fce4e1ee%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Sachin Nikam
2013-Dec-09 21:54 UTC
[Puppet Users] Re: puppet apply manifest command line parameters
Jake, Thanks for the info. My puppet manifest is doing the same thing as bash script. Regards Sachin On Monday, 9 December 2013 13:29:52 UTC-8, Jake Lundberg wrote:> > No, not like that. > > You could create your own custom fact and use that via command line. See: > http://www.practicalclouds.com/content/guide/converting-user-data-arguments-facts. > It''s not a perfect example, but does have some logic for parsing > arguments. > > As you''re a self proclaimed newbie, this may take longer than you wish. > > Another option is you can wrap creating your manifest (site.pp or imports) > in a script, but that''s probably not the ideal solution. > > What are you trying to do? Arbitrary remote execution of commands? If > so, Puppet might not be the best platform. Consider something like > Fabric/Capistrano, Ansible or Salt Stack (or just plain Bash). > > > On Monday, December 9, 2013 12:50:44 PM UTC-8, Sachin Nikam wrote: >> >> Jake, >> I want to do something like this... >> # puppet apply --modulepath=/etc/puppet/modules site.pp "somevalue1" >> "somevalue2" >> >> is this possible? >> Regards >> Sachin >> >> On Monday, 9 December 2013 11:48:16 UTC-8, Jake Lundberg wrote: >>> >>> Oops, that should probably read: >>> >>> exec { "do something" : >>> command => "/usr/local/bin/exec_something.sh ${param1} ${param2}" >>> } >>> >>> On Monday, December 9, 2013 11:46:17 AM UTC-8, Jake Lundberg wrote: >>>> >>>> I suppose it depends on how you structure your manifest. We typically >>>> apply a manifest to a particular node when testing new manifests. So >>>> something like: >>>> >>>> site.pp: >>>> node default { >>>> $param1 = "value1" >>>> $param2 = "value2" >>>> >>>> include exec_class >>>> } >>>> >>>> /etc/puppet/modules/exec_class/manifests/init.pp >>>> class exec_class ( $param1, $param2) { >>>> >>>> exec { "do something" : >>>> command => "/usr/local/bin/exec_something.sh" >>>> } >>>> } >>>> >>>> # puppet apply --modulepath=/etc/puppet/modules site.pp >>>> >>>> I also think you can pass parameters via facter: >>>> http://stackoverflow.com/questions/15901850/pass-variable-to-puppet-on-commandline >>>> >>>> On Sunday, December 8, 2013 7:31:27 PM UTC-8, Sachin Nikam wrote: >>>>> >>>>> I am newbie to puppet(versin 2.7) and came up with a manifest that >>>>> contains some "exec" tasks. when I invoke the puppet apply <manifest>, I >>>>> want to pass in some parameters specific to my application. How do I do >>>>> that? I searched the online documentation but couldn''t find any examples. >>>>> Regards >>>>> Sachin >>>>> >>>>-- 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/1575abe5-ee13-4f70-b26e-509290b0d13f%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Felix Frank
2013-Dec-15 17:04 UTC
Re: [Puppet Users] Re: puppet apply manifest command line parameters
Custom facts is a good keyword, and you can get the same effect easier: FACTER_param1=foo FACTER_param2=bar puppet apply /my/manifest.pp The "facts" $::param1 and $::param2 will be available to puppet. Note that it is likely preferable to write an actual bash script instead of a puppet manifest for this. The whole approach sounds as if you''re using puppet in a way that doesn''t cater to its strengths, and hempers you with some of its weeknesses. HTH, Felix On 12/09/2013 10:29 PM, Jake Lundberg wrote:> > You could create your own custom fact and use that via command line. > See: http://www.practicalclouds.com/content/guide/converting-user-data-arguments-facts. > It''s not a perfect example, but does have some logic for parsing > arguments.-- 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/52ADE126.4020701%40Alumni.TU-Berlin.de. For more options, visit https://groups.google.com/groups/opt_out.