- From: Iain Prior <
>
- To: "
" <
>
- Subject: [chef] Windows and powershell_out
- Date: Mon, 27 Oct 2014 09:06:33 +0000
- Accept-language: en-US, sv-SE
- Acceptlanguage: en-US, sv-SE
Hi guys
I have managed to properly confuse myself well and truly!
Scenario: Basic Chef installation, server is Ubuntu 12.04, client is windows
2012 server.
What I want to do: Read the "version" property of a file into an attribute of
a node.
What I've tried: You can see my attempt below. It seems that the
PowerShellOut "mixin" is not available, but I'm too scared to add the windows
and powershell cookbooks to my collection, because I understand that they are
already included in the latest chef. So now I'm stuck! Help!!!
The powershell code below runs and creates the text file fine, but how do I
get the value from the text file into the attribute?
The Code:
powershell_script 'filever' do
code <<-EOH
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\\Program
Files\\Internet Explorer\\iexplore.exe").FileVersion >
C:\\windows\\temp\\fileversion.txt
get-content -Path C:\\windows\\temp\\fileversion.txt
EOH
end
powershell_script 'filever2' do
::Chef::Recipe.send(:include, Chef::Mixin::PowershellOut)
#include Chef::Mixin::PowershellOut
node.normal[:ixserver][:Hello] = powershell_out("echo hello")
end
I'm hoping you guys can help..
Many regards
Iain
- [chef] Windows and powershell_out, Iain Prior, 10/27/2014
Archive powered by MHonArc 2.6.16.