Copy files from file resource to target folder

Greetings professionals

Can any one please help me how share a directory from cookbook_file resource to target windows server exact path

I am trying to install Appdymanics machine agent windows version , there is no setup.exe file available we need to copy the entire directory to remote server to target path and run the VB script which installs appd agent.

i have copied the appd directory to my cookbook_file directory and trying to push that to target path which is C:\Program Files (x86) but unable to do it , when ever i tried to bootstrap the windows node i could able to see cookbook_file under path C:\chef\cache\cookbooks\appd-windows

I tried using windows commands in the recipe to move folder from default path to target path but it fails
below is the recipe im using

windows_package ‘appdynamics’ do
source 'file:///C:/chef/cache/cookbooks/appd-windows
action :nothing
end

execute ‘appd-windows’ do
command ’ C:\chef\cache\cookbooks\appd-windows>move C:\Program Files (x86)’ #/E’
end

Please help…!

Thanks
prash

Good morning Prash,

Here is the logic I use to install and configure the AppDynamics agent.

Create AppD template file

cookbook_file "#{node['serverInfo']['tools_dir']}/appd_template.xml" do
source "_appd_template.xml"
action :create
end

cookbook_file "#{node['serverInfo']['tools_dir']}\dotNetAgentSetup.msi" do
source 'dotNetAgentSetup.msi'
action :create
end

Install AppDynamics Agent

windows_package 'appdynamics' do
action :install
source "#{node['serverInfo']['tools_dir']}\dotNetAgentSetup.msi"
options "/q /norestart /lv "#{node['serverInfo']['tools_dir']}\AgentInstaller.log" AD_SetupFile="#{node['serverInfo']['tools_dir']}\appd_template.xml""
end

the node[‘serverInfo’][‘tools_dir’] is an attribute I define that points to a local path on a server where we keep installer files and various tools for administrative use.

So basically I store the current AppD installer file and various AppD template files in my cookbook, I copy both down to the server and then use the windows_package resource to install and configure it.

Brian

Just as a side note: Cookbooks are not supposed to be file storages and the Chef Server is not optimized to server large binary files. You will run into massive troubles quite soon if you really store MSI or any other large files in your cookbooks.
You should use Artifactory or similar for that or at least keep the files on a File share.

You have a sample of how to do that? Tried but failed.

remote_file 'copyfile2' do
atomic_update false
source 'file:////mysharechef_file_create.ps1'
path 'c:/temp/chef_file_create.ps1'
end

windows_package 'WindowsSensor' do
source 'file:///C:/chef/cache/cookbooks/CrowdStrike-windows/files/default/WindowsSensor.exe'
options "/install /quiet /norestart "
installer_type :msi
action :install
end

This is how i copied the file or dir from source to remote location...

Doesnt look like that file in windows share. windows_package , is that dependent on any other libraries?

tried this windows_package '7zip' do
source 'http://www.7-zip.org/a/7z938-x64.msi'
action :install
end
but failed
Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - Connection refused connecting to http://www.7-zip.org/a/7z938-x64.msi, giving up

No it is under files directory under the custom cookbook

We have large msi files and cannot store those with cookbook_name/files. However did try a simple bat file and it did copy. Any other ideas?