Using node.run_state['variable'] in a powershell script

Hi All,

I'm struggling to get the value out of this variable into my powershell script. the default.rb file runs something similar to the following:

aws_ssm_parameter_store 'proxydns' do
path '/rendev/proxy/proxy'
return_key 'proxydns'
action :get
end

aws_ssm_parameter_store 'proxybypass' do
path '/rendev/proxy/bypass'
return_key 'proxybypass'
action :get
end

file 'c:\temp\proxydns.txt' do
content lazy { node.run_state['proxydns'] + node.run_state['proxybypass'] }
end

powershell_script 'test_variables' do

code <<-EOH
Set-Content -Path C:\temp\psoutput.log -Value "#{node.run_state['proxydns']}"
Add-Content -Path C:\temp\psoutput.log -Value "#{node.run_state['proxybypass']}"
EOH

end

The parameter store calls and the file call all work as expected, but when I use the node.run_state['variable'] in my powershell script the value it outputs is empty...

I'm guessing it's because using 'lazy' in the file context runs the code block and returns the value?

so I'm assuming what I need to due to somehow insert the return value from the code block into a variable that I can then pass into my powershell code.

Any help as always most appreciated.

Chris.

1 Like