Samir, are you aware of the slack.puppet.com website? It is free and you can chat/IM with people real-time about your code. That's the first thing.
Secondly are you aware of the Puppet.com pages for code writing? Check this page: https://docs.puppet.com/puppet/4.9/lang_conditional.html or this page - https://docs.puppet.com/puppet/4.9/lang_conditional.html#if-statements Change the version drop-down box to match your Puppet Server version? Also, are you aware of the builtin Puppet facts that you can use? You mentioned that you are using $env variable "from?" hostname, there is a facter (fact) for hostname; are you aware of that? I too am relatively newbie, but I am getting better with every new and challenging module I write. Finally, what error are you getting when you use this module? Copy/paste the output as the result of *puppet parser validate * */path/to/your/module/manifest/init.pp* (or whatever your .PP file is called). -------------------------- Warron French On Mon, May 1, 2017 at 7:36 PM, Samir Gahirwal <[email protected]> wrote: > Hi, > > I am very new to puppet and writing my first class :) Please pardon me for > asking basic question > > I am trying to write module to run install script. Can someone help me > with syntax or suggest better way to code following > > define install-package { > if ( $env != 'test' or $env != 'qa') { > case $::package_type { > 'abc': { > $variable = '123' > } > 'xyz': { > $variable = '345' > } > exec {"run_my_script": > source => "puppet:///modules/mymodule/resources/myinstall > script.sh", > command => 'sh myscript.sh $variable' > } > > } > else { > case $::package_type { > 'abc': { > $variable = '567' > } > 'xyz': { > $variable = '789' > } > } > exec {"run_my_script": > source => "puppet:///modules/mymodule/resources/myinstall > script.sh", > command => 'sh myscript.sh $variable' > } > } > > class mymodule::software { > $package_type = unique([jdk,apache,tomcat]) > install-package { $package_type:; } > } > > I am deriving env variable from host name. > > Let me know if you need additional details. > > Thanks! > --SamirG > > -- > 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 [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/puppet-users/ecb68180-af56-4d36-a555-236a69efea50%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/ecb68180-af56-4d36-a555-236a69efea50%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAJdJdQnQU5CQkUp9Q3cEgMnGz5Tw1ZrKaFveNFU1di%2BD5cKCvw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
