sasikiran v
2013-Nov-25 08:54 UTC
[Puppet Users] How to store "bash command:" output in a variable as array
exec {''ls'': command => "ls", path => "/usr/bin:/bin", provider => shell, } So the output of "ls" contains files/directories, these should be stored in a array for suppose "$my_array" and it should be used globally in the module. Can any one help me in this -- 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/b53e7979-7d5c-40a1-8110-731ab0f45179%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Johan De Wit
2013-Nov-25 09:38 UTC
Re: [Puppet Users] How to store "bash command:" output in a variable as array
Hi, You should have a look at ''facts''. An exec is executed in the last phase of a puppet run. If you need information form a node, that you need in eg. templates, modules etc, you will have to use facts. Have a look at the last image on http://puppetlabs.com/puppet/what-is-puppet Writing simple custom facts is not that difficult. http://docs.puppetlabs.com/guides/custom_facts.html hth Grts jo On 11/25/2013 09:54 AM, sasikiran v wrote:> exec {''ls'': > command => "ls", > path => "/usr/bin:/bin", > provider => shell, > } > > So the output of "ls" contains files/directories, these should be > stored in a array for suppose "$my_array" and it should be used > globally in the module. > > Can any one help me in this > -- > 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/b53e7979-7d5c-40a1-8110-731ab0f45179%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- Johan De Wit Open Source Consultant Red Hat Certified Engineer (805008667232363) Puppet Certified Professional 2013 (PCP0000006) _________________________________________________________ Open-Future Phone +32 (0)2/255 70 70 Zavelstraat 72 Fax +32 (0)2/255 70 71 3071 KORTENBERG Mobile +32 (0)474/42 40 73 BELGIUM http://www.open-future.be _________________________________________________________ Next Events: Puppet Advanced Training | https://www.open-future.be/puppet-advanced-training-12-till-14th-november Zabbix Certified Training | http://www.open-future.be/zabbix-certified-training-18-till-20th-november Zabbix Large Environments Training | http://www.open-future.be/zabbix-large-environments-training-21-till-22nd-november Puppet Fundamentals Training | http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december Subscribe to our newsletter | http://eepurl.com/BUG8H -- 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/52931A94.9050208%40open-future.be. For more options, visit https://groups.google.com/groups/opt_out.
Štěpán Cenek
2013-Nov-25 12:22 UTC
Re: [Puppet Users] How to store "bash command:" output in a variable as array
Hi y''all, creating custom fact is great. If you need it just for testing, use generate. $arr = generate(''/bin/ls'') Btw: the difference between exec and generate is that generate is executed right on the beginning of Puppet run (so it will fail if it''s using tool installed later by Puppet). You will get only exit code from exec, not the output. -- *Stepan Cenek* System Engineer *GoodData* | twitter <https://twitter.com/gooddata> | facebook<https://www.facebook.com/gooddata> | linkedin <http://www.linkedin.com/company/gooddata> | blog<http://www.gooddata.com/blog> Dne pondělí, 25. listopadu 2013 10:38:28 UTC+1 Johan De Wit napsal(a):> > Hi, > > You should have a look at ''facts''. > > An exec is executed in the last phase of a puppet run. If you need > information form a node, that you need in eg. templates, modules etc, > you will have to use facts. > > Have a look at the last image on > http://puppetlabs.com/puppet/what-is-puppet<http://www.google.com/url?q=http%3A%2F%2Fpuppetlabs.com%2Fpuppet%2Fwhat-is-puppet&sa=D&sntz=1&usg=AFQjCNGPWXvADxUpY3lqb5F-_1LXgne3dQ> > > Writing simple custom facts is not that difficult. > http://docs.puppetlabs.com/guides/custom_facts.html<http://www.google.com/url?q=http%3A%2F%2Fdocs.puppetlabs.com%2Fguides%2Fcustom_facts.html&sa=D&sntz=1&usg=AFQjCNFyhPYA7PJYjge6kYzuWtfutMVSnw> > > hth > > Grts > > jo > > > > > On 11/25/2013 09:54 AM, sasikiran v wrote: > > exec {''ls'': > > command => "ls", > > path => "/usr/bin:/bin", > > provider => shell, > > } > > > > So the output of "ls" contains files/directories, these should be > > stored in a array for suppose "$my_array" and it should be used > > globally in the module. > > > > Can any one help me in this > > -- > > 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...@googlegroups.com <javascript:>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/puppet-users/b53e7979-7d5c-40a1-8110-731ab0f45179%40googlegroups.com. > > > For more options, visit https://groups.google.com/groups/opt_out. > > > -- > Johan De Wit > > Open Source Consultant > > Red Hat Certified Engineer (805008667232363) > Puppet Certified Professional 2013 (PCP0000006) > _________________________________________________________ > > Open-Future Phone +32 (0)2/255 70 70 > Zavelstraat 72 Fax +32 (0)2/255 70 71 > 3071 KORTENBERG Mobile +32 (0)474/42 40 73 > BELGIUM http://www.open-future.be<http://www.google.com/url?q=http%3A%2F%2Fwww.open-future.be&sa=D&sntz=1&usg=AFQjCNHjoCBMolUQJGvRKn9s5R3o6wHzeA> > _________________________________________________________ > > > Next Events: > Puppet Advanced Training | > https://www.open-future.be/puppet-advanced-training-12-till-14th-november<https://www.google.com/url?q=https%3A%2F%2Fwww.open-future.be%2Fpuppet-advanced-training-12-till-14th-november&sa=D&sntz=1&usg=AFQjCNEjqSEE109-79k2V4zSBeEayUxE4w> > Zabbix Certified Training | > http://www.open-future.be/zabbix-certified-training-18-till-20th-november<http://www.google.com/url?q=http%3A%2F%2Fwww.open-future.be%2Fzabbix-certified-training-18-till-20th-november&sa=D&sntz=1&usg=AFQjCNGE39dllnTwZNJoNI7nsA7EDFW8hA> > Zabbix Large Environments Training | > http://www.open-future.be/zabbix-large-environments-training-21-till-22nd-november<http://www.google.com/url?q=http%3A%2F%2Fwww.open-future.be%2Fzabbix-large-environments-training-21-till-22nd-november&sa=D&sntz=1&usg=AFQjCNFZ6RAuMu2KpJgfdtEH7hi2X20UdQ> > Puppet Fundamentals Training | > http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december<http://www.google.com/url?q=http%3A%2F%2Fwww.open-future.be%2Fpuppet-fundamentals-training-10-till-12th-december&sa=D&sntz=1&usg=AFQjCNF6sb1kbedYyRH1cH2DZBpigEDKEQ> > Subscribe to our newsletter | http://eepurl.com/BUG8H<http://www.google.com/url?q=http%3A%2F%2Feepurl.com%2FBUG8H&sa=D&sntz=1&usg=AFQjCNEthqltBE0AvNgTivU3N-0ecv1f6w> >-- 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/414da305-624f-4581-ae43-b0924f6fbd6e%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Paul Tötterman
2013-Nov-25 15:03 UTC
Re: [Puppet Users] How to store "bash command:" output in a variable as array
> > Btw: the difference between exec and generate is that generate is executed > right on the beginning of Puppet run >No. The difference is that generate() is run on the master and exec on the agent: http://docs.puppetlabs.com/references/latest/function.html#generate Cheers, Paul -- 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/3d8c7c6c-fbef-45c3-a30b-594ab5b73be1%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Stepan Cenek
2013-Nov-25 15:13 UTC
Re: [Puppet Users] How to store "bash command:" output in a variable as array
Sorry for confusion, I''m used to masterless Puppet... On Mon, Nov 25, 2013 at 4:03 PM, Paul Tötterman <paul.totterman@gmail.com> wrote:>> Btw: the difference between exec and generate is that generate is executed >> right on the beginning of Puppet run > > > No. The difference is that generate() is run on the master and exec on the > agent: http://docs.puppetlabs.com/references/latest/function.html#generate > > Cheers, > Paul > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Puppet Users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/puppet-users/mnrRLQHTnMs/unsubscribe. > To unsubscribe from this group and all its topics, 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/3d8c7c6c-fbef-45c3-a30b-594ab5b73be1%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/CALWnDfpHN4YMiGtNysQ%3DXyffRR_YfUzCCVFrU4kqxXZdZ1fGgw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.