Thanks for this rob. I still cannot get the variable to pass into the script. Now i have the *setdnsforwarders.ps1.erb* template, and here is the complete copy of what is in the template:
$outside = <%= scope['dnsforwarders'] %> $outside | out-file C:\output.log -append I've also tried the following: <%= scope.lookupvar('@dnsforwarders') %> | out-file C:\output.log -append <%= scope.lookupvar('windows_dns::forwarders') %> | out-file C:\output.log -append <%= scope.lookupvar('windows_dns::config') %> | out-file C:\output.log -append Each time the output.log file is blank. Here is my windows_dns::config file: class windows_dns::config { case $kernelmajversion { 6.3: { $forwarder_execute = 'windows_dns/setdnsforwarders.ps1.erb' $forwarder_check = 'windows_dns/checkdnsforwarders.ps1' $dnsforwarders = $windows_dns::forwarders } 6.1: { $forwarder_execute = 'windows_dns/setdnsforwarders_legacy.ps1' $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1' } } exec { 'forwarderscreate': command => template ($forwarder_execute), #unless => template ($forwarder_check), provider => powershell, logoutput => true, } And here is where the variable is originally defined in the windows_dns::init.pp class windows_dns( $forwarders = '1.1.1.1' ) { anchor { 'windows_dns::begin': } -> class{'windows_dns::install': } -> class{'windows_dns::config': } -> class{'windows_dns::service': } -> anchor { 'windows_dns::end': } } Any help would be amazing to get the variable to pass On Friday, October 10, 2014 5:28:06 PM UTC-4, Rob Reynolds wrote: > > > > On Thu, Oct 9, 2014 at 4:18 PM, Paul Ponzeka <ponz...@gmail.com > <javascript:>> wrote: > >> Thanks josh, so in my template file setdnsforwarders.ps1 is this the >> correct syntax? >> > > setdnsforwarders.ps1.erb > > >> >> $outside = <%= scope['dnsforwarders'] %> >> $outside | out-file C:\output.log -append >> >> >> On Thursday, October 9, 2014 4:52:04 PM UTC-4, Josh Cooper wrote: >>> >>> >>> >>> On Thu, Oct 9, 2014 at 12:59 PM, Juan Andres Ramirez <jandr...@gmail.com >>> > wrote: >>> >>>> Example: >>>> >>>> I have my script on powershell in the next path >>>> >>>> in Puppet: >>>> >>>> define some::module() { >>>> $script = "\\\\server1\\shared\\script.ps1 >>>> >>>> exec { "Executing a script": >>>> command => "powershell.exe -ExecutionPolicy ByPass -File >>>> ${script} ${param1}", >>>> unless => "powershell.exe -ExecutionPolicy ByPass >>>> -command \"here any command on powershell \"" >>>> } >>>> >>>> >>>> >>>> On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote: >>>> >>>>> I am using Puppet installed with the powershell module. I am >>>>> struggling with how to pass a puppet variable through to powershell. For >>>>> instance I have the following in my module *init.pp* file: >>>>> >>>>> class windows_dns( >>>>> >>>>> $forwarders = '1.1.1.1' >>>>> >>>>> ) { >>>>> anchor { 'windows_dns::begin': } -> >>>>> class{'windows_dns::install': } -> >>>>> class{'windows_dns::config': } -> >>>>> class{'windows_dns::service': } -> >>>>> anchor { 'windows_dns::end': } >>>>> >>>>> } >>>>> >>>>> >>>>> Then in my *config.pp* file I have: >>>>> >>>>> class windows_dns::config { >>>>> >>>>> case $kernelmajversion { >>>>> 6.3: { >>>>> $forwarder_execute = >>>>> 'windows_dns/setdnsforwarders.ps1' >>>>> $forwarder_check = 'windows_dns/checkdnsforwarders.ps1' >>>>> $dnsforwarders = $windows_dns::forwarders >>>>> >>>>> } >>>>> 6.1: { >>>>> $forwarder_execute = >>>>> 'windows_dns/setdnsforwarders_legacy.ps1' >>>>> $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1' >>>>> >>>>> } >>>>> } >>>>> >>>>> exec { 'forwarderscreate': >>>>> >>>>> command => template ($forwarder_execute), >>>>> unless => template ($forwarder_check), >>>>> provider => powershell, >>>>> logoutput => true, >>>>> >>>>> } >>>>> >>>>> I have stored as a template in the manifest a powershell script file >>>>> as: >>>>> >>>>> $dnsforwarders | out-file C:\test.log >>>>> >>>>> I obviously want to use a more complex output. I tried adding a >>>>> parameter to the top of my powershell script but dont understand how to >>>>> pass that as an option to puppet. >>>>> >>>>> The variable passes through fine. I tested by changing the command to >>>>> *command=> >>>>> template ($dnsforwarders)* and i of course got an error from puppet >>>>> about it not being able to find the template named *1.1.1.1* in the >>>>> manifest. I just dont know how to pass this through to the shell. >>>>> >>>> -- >>>> 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. >>>> To view this discussion on the web visit https://groups.google.com/d/ >>>> msgid/puppet-users/c62b8af5-4890-4a84-905e-63e7b6132e13% >>>> 40googlegroups.com >>>> <https://groups.google.com/d/msgid/puppet-users/c62b8af5-4890-4a84-905e-63e7b6132e13%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> I would recommend using the powershell provider as you were doing. In >>> your powershell script 'windows_dns/setdnsforwarders.ps1', resolve >>> parameters using ERB syntax found in https://docs.puppetlabs.com/ >>> guides/templating.html#referencing-variables, something like: >>> >>> <%= scope['dnsforwarders'] %> >>> >>> Josh >>> >>> -- >>> Josh Cooper >>> Developer, Puppet Labs >>> >> -- >> 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/961dd225-1159-48fe-a9bf-c727bf094b74%40googlegroups.com >> >> <https://groups.google.com/d/msgid/puppet-users/961dd225-1159-48fe-a9bf-c727bf094b74%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Rob Reynolds > Developer, Puppet Labs > > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d23ddc00-af07-462d-9a99-1a9d668bce32%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.