I am trying to install a package from a mapped drive. However, chef says my source path is an invalid location even though I know it is the correct location. Do I need to map the drive first, before Chef recognizes the source path? I looked online in a couple places and could not find an answer.
case node['platform']
when 'windows'
windows_package 'QualysCloudAgent' do
source '\\Server#\Location1\Qualys_agent\QualysCloudAgent.exe'
options '-argumentlist "CustomerId={etc...etc...etc..} ActivationId={etc...etc..etc...}"'
installer_type :custom
action :install
end
end
The error that I get when the chef client runs is that the source location is in invalid source, even though I can get to the source location by typing it in on the server itself. Any help would be appreciated. Thank you. Error That I receive is below.
* Source for package QualysCloudAgent does not exist
================================================================================
Error executing action `install` on resource 'windows_package[QualysCloudAgent]'
================================================================================
Chef::Exceptions::Package
-------------------------
Source for package QualysCloudAgent does not exist
Resource Declaration:
---------------------
# In c:/chef/cache/cookbooks/qualys/recipes/qualys_configure.rb
18: windows_package 'QualysCloudAgent' do
19: source '\\Server#\Location1\Qualys_agent\QualysCloudAgent.exe'
20: options '-argumentlist "CustomerId={etc...etc...etc...} ActivationId={etc...etc...etc...}"'
21: installer_type :custom
22: action :install
23: end
24: end
Compiled Resource:
------------------
# Declared in c:/chef/cache/cookbooks/qualys/recipes/qualys_configure.rb:18:in `from_file'
windows_package("QualysCloudAgent") do
package_name "QualysCloudAgent"
action [:install]
default_guard_interpreter :default
declared_type :windows_package
cookbook_name "qualys"
recipe_name "qualys_configure"
source "p:\\Server#\\Location1\\qualys_agent\\qualyscloudagent.exe"
options "-argumentlist \"CustomerId={etc...etc...etc...} ActivationId={etc...etc...etc...}\""
installer_type :custom
end
System Info:
------------
chef_version=14.14.25
platform=windows
platform_version=6.3.9600
ruby=ruby 2.5.7p206 (2019-10-01 revision 67816) [x64-mingw32]
program_name=C:/opscode/chef/bin/chef-client
executable=C:/opscode/chef/bin/chef-client
2020-01-12T22:21:50-08:00] INFO: Running queued delayed notifications before re-raising exception
unning handlers:
2020-01-12T22:21:50-08:00] ERROR: Running exception handlers
unning handlers complete
2020-01-12T22:21:50-08:00] ERROR: Exception handlers complete
hef Client failed. 0 resources updated in 14 seconds
2020-01-12T22:21:51-08:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
2020-01-12T22:21:51-08:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
2020-01-12T22:21:51-08:00] FATAL: Chef::Exceptions::Package: windows_package[QualysCloudAgent] (qualys::qualys_configur
line 18) had an error: Chef::Exceptions::Package: Source for package QualysCloudAgent does not exist
Since you're installing a package, it's safe to assume you are running chef-client with elevated permissions. Any network drives you map that are visible in Explorer, will not be usable in an elevated process. You will either need to:
Use the UNC path in place of a letter drive
Map the drive during the Chef run (required if the full UNC path would exceed 255 characters)
If you opt for the latter approach, you can use the mount resource to map a network drive.
Related
Error executing action `install` on resource 'windows_package[autologon]'
================================================================================
Chef::Exceptions::CannotDetermineWindowsInstallerType
-----------------------------------------------------
Installer type for Windows Package 'autologon' not specified and cannot be determined from file extension 'exe'
Resource Declaration:
---------------------
# In C:/Users/kitchen/AppData/Local/Temp/kitchen/cache/cookbooks/rclient/recipes/windows.rb
26: windows_package 'autologon' do
27: source "#{node['rclient']['remote_root_url']}/autologon/3.10/Autologon.exe"
28: end
29:
Also same issue for IEDriverServer.exe and msys2-x86_64-20161025.exe packages.
See https://docs.chef.io/resource_windows_package.html for information. You almost certainly need to specify :installer_type.
https://github.com/chef/chef/blob/master/lib/chef/provider/package/windows.rb#L91 is the method where the error you see is being produced.
I am using chef client to run cookbook with docker. It run on Ubuntu, but gives error on windows. Dependency of docker is already added in cookbook.
https://supermarket.chef.io/cookbooks/docker
I am using example of docker cookbook.
docker_image 'busybox' do
action :pull
end
Error :
Recipe: tomcatcookbook::default
* docker_image[busybox] action pull[2017-11-01T14:02:43+05:30] INFO: Processing docker_image[busybox] action pull (tomcatcookbook::default line 6)
================================================================================
Error executing action `pull` on resource 'docker_image[busybox]'
================================================================================
Excon::Error::Socket
--------------------
An address incompatible with the requested protocol was used. - socket(2) (Errno::EAFNOSUPPORT)
Resource Declaration:
---------------------
# In C:/chef/cache/cookbooks/tomcatcookbook/recipes/default.rb
6: docker_image 'busybox' do
7: action :pull
8: end
9:
Compiled Resource:
------------------
# Declared in C:/chef/cache/cookbooks/tomcatcookbook/recipes/default.rb:6:in `from_file'
docker_image("busybox") do
action [:pull]
default_guard_interpreter :default
declared_type :docker_image
cookbook_name "tomcatcookbook"
recipe_name "default"
repo "busybox"
connection #<Docker::Connection:0x0000000005a288c0 #url="unix:///", #options={:socket=>"/var/run/docker.sock", :read_timeout=>120}>
end
System Info:
------------
chef_version=13.5.3
platform=windows
platform_version=10.0.15063
ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x64-mingw32]
program_name=C:/opscode/chef/bin/chef-client
executable=C:/opscode/chef/bin/chef-client
[2017-11-01T14:02:44+05:30] INFO: Running queued delayed notifications before re-raising exception
As you can see in the documentation (the platform support list), Windows is not supported by that cookbook.
I've created a simple recipe to copy files from one directory to another on windows.
Recipe:
remote_directory 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination' do
source 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\source'
action :create
end
However, I'm getting the following error when trying to execute the recipe in --local-mode for the sake of testing the recipe before deploying it on Chef server:
PS C:\chef-repo\chef-repo\cookbooks\chef-repo> chef-client
--local-mode .\copyBinaries.rb [2017-08-08T13:34:03+03:00] INFO: Started chef-zero at chefzero://localhost:1 with repository at C:/chef-repo/chef-repo One version per cookbook
Starting Chef Client, version 13.2.20 [2017-08-08T13:34:03+03:00] INFO: *** Chef 13.2.20 *** [2017-08-08T13:34:03+03:00] INFO: Platform: i386-mingw32 [2017-08-08T13:34:03+03:00] INFO: Chef-client pid: 10708 [2017-08-08T13:34:03+03:00] INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping... [2017-08-08T13:34:12+03:00] INFO: Run List is [] [2017-08-08T13:34:12+03:00] INFO: Run List expands to [] [2017-08-08T13:34:12+03:00] INFO: Starting Chef Run for mohammedr [2017-08-08T13:34:12+03:00] INFO: Running start handlers [2017-08-08T13:34:12+03:00] INFO: Start handlers complete. resolving cookbooks for run list: [] [2017-08-08T13:34:12+03:00] INFO: Loading cookbooks [] Synchronizing Cookbooks: Installing Cookbook Gems: Compiling Cookbooks... [2017-08-08T13:34:12+03:00] WARN: Node mohammedr has an empty run list. Converging 1 resources Recipe: #recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb
* remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] action create[2017-08-08T13:34:12+03:00] INFO: Processing remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] action create (#recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb line 7)
================================================================================
Error executing action `create` on resource 'remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination]'
================================================================================
Chef::Exceptions::CookbookNotFound
----------------------------------
Cookbook #recipe_files not found. If you're loading #recipe_files from another cookbook, make sure you configure the dependency in your metadata
Resource Declaration:
---------------------
# In C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb
7: remote_directory 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination' do
8: source 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\source'
9: action :create
10: end
11:
Compiled Resource:
------------------
# Declared in C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb:7:in `from_file'
remote_directory("C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination") do
action [:create]
default_guard_interpreter :default
path "C:\\chef-repo\\chef-repo\\cookbooks\\chef-repo\\recipes\\destination"
recursive true
source "C:\\chef-repo\\chef-repo\\cookbooks\\chef-repo\\recipes\\source"
files_backup 5
files_owner nil
files_group nil
overwrite true
declared_type :remote_directory
cookbook_name "#recipe_files"
recipe_name "C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb"
mode nil
owner nil
group nil
files_mode nil
end
System Info:
------------
chef_version=13.2.20
platform=windows
platform_version=10.0.14393
ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
program_name=C:/opscode/chefdk/modules/chef/../../bin/chef-client
executable=C:/opscode/chefdk/bin/chef-client
[2017-08-08T13:34:12+03:00] INFO: Running queued delayed notifications before re-raising exception
Running handlers: [2017-08-08T13:34:12+03:00] ERROR: Running exception handlers Running handlers complete [2017-08-08T13:34:12+03:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated in 09 seconds [2017-08-08T13:34:12+03:00] FATAL: Stacktrace dumped to c:/chef-repo/chef-repo/.chef/local-mode-cache/cache/chef-stacktrace.out [2017-08-08T13:34:12+03:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2017-08-08T13:34:12+03:00] FATAL: Chef::Exceptions::CookbookNotFound: remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] (#recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb line 7) had an error: Chef::Exceptions::CookbookNotFound: Cookbook #recipe_files not found. If you're loading #recipe_files from another cookbook, make sure you configure the dependency in your metadata
I've tried searching the internet for a solution regarding this issue, but I couldn't find anything useful.
The remote_directory resource takes files from the cookbook's files/ folder.
What you do looks pretty weird to me - you're copying recipes, and you're hardcoding local paths to the cookbook. Better ask a new question including your actual goal. I'm pretty confident that remote_directory is not what you want.
Recipe:
include_recipe "lgjava"
include_recipe "lgtomcat"
remote_file "/usr/local/tomcat7/webapps/web.war" do #this file places web.war in the specified path
source "http://path/to/web.war"
action :create_if_missing
end
template "jdoconfig.xml" do
source "jdoconfig.xml.erb"
path "/usr/local/tomcat7/webapps/web/WEB-INF/classes/META-INF/jdoconfig.xml"
action :create_if_missing
mode "0755"
end
template "appname.properties" do
source "appname.properties.erb"
path "/usr/local/tomcat7/webapps/web/WEB-INF/classes/appname.properties"
action :create_if_missing
mode "0755"
end
Execution:
Recipe: lgwebapp::default
* remote_file[/usr/local/tomcat7/webapps/web.war] action create_if_missing
- create new file /usr/local/tomcat7/webapps/web.war
- update content in file /usr/local/tomcat7/webapps/web.war from none to ac4b77
(file sizes exceed 10000000 bytes, diff output suppressed)
- restore selinux security context
* template[jdoconfig.xml] action create_if_missing
* Parent directory /usr/local/tomcat7/webapps/web/WEB-INF/classes/META-INF does not exist.
================================================================================
Error executing action `create_if_missing` on resource 'template[jdoconfig.xml]'
================================================================================
Chef::Exceptions::EnclosingDirectoryDoesNotExist
------------------------------------------------
Parent directory /usr/local/tomcat7/webapps/web/WEB-INF/classes/META-INF does not exist.
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/lgwebapp/recipes/default.rb
20: template "jdoconfig.xml" do
21: source "jdoconfig.xml.erb"
22: path "/usr/local/tomcat7/webapps/web/WEB-INF/classes/META-INF/jdoconfig.xml"
23: action :create_if_missing
24: mode "0755"
25: end
26:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/lgwebapp/recipes/default.rb:20:in `from_file'
template("jdoconfig.xml") do
provider Chef::Provider::Template
action [:create_if_missing]
retries 0
retry_delay 2
guard_interpreter :default
path "/usr/local/tomcat7/webapps/web/WEB-INF/classes/META-INF/jdoconfig.xml"
backup 5
atomic_update true
source "jdoconfig.xml.erb"
cookbook_name "lgwebapp"
recipe_name "default"
mode "0755"
end
Recipe: lgtomcat::default
* service[tomcat7] action restart
- restart service service[tomcat7]
Running handlers:
[2015-01-14T10:38:44+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-01-14T10:38:44+00:00] ERROR: Exception handlers complete
[2015-01-14T10:38:44+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 6 resources updated in 6.532117395 seconds
[2015-01-14T10:38:44+00:00] ERROR: template[jdoconfig.xml] (lgwebapp::default line 20) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /usr/local/tomcat7/webapps/web/WEB-INF/classes/META-INF does not exist.
[2015-01-14T10:38:44+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
P.S: the web.war file is deployed under tomcat7/webapps and its extracted too. I manually checked it, the file exists in the specific location. Why is that it's not able to locate using 'templates'?
Take it as stream:
Chef deploys the war then renders the template and try to compare with existing file.
The problem is that when chef tries to get the target file info, Tomcat probably has not yet unpacked the war file at all.
We do this kind of deployment with an ark resource out of tomcat, render the templates and then copy or link (depending on the cases) the temp deploy dir to the webapps tomcat dir.
The below code solved my problem:
ruby_block 'wait for tomcat' do
block do
true until ::File.exists?("#{node['webapp']['webinf_dir']}")
end
end
I am running a recipe which I have used a bazillion times before, and im getting these errors when I spin up a new EC2 instance with chef + knife.
[2013-01-30T23:44:48+00:00] INFO: Processing user[dan] action create (/var/chef/cache/cookbooks/users/providers/manage.rb line 65)
[2013-01-30T23:44:48+00:00] INFO: user[dan] created
[2013-01-30T23:44:48+00:00] INFO: Processing directory[/home/dan/.ssh] action create (/var/chef/cache/cookbooks/users/providers/manage.rb line 81)
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] created directory /home/dan/.ssh
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] owner changed to 2003
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] group changed to 2003
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] mode changed to 700
[2013-01-30T23:44:48+00:00] INFO: Processing template[/home/dan/.ssh/authorized_keys] action create (/var/chef/cache/cookbooks/users/providers/manage.rb line 88)
[2013-01-30T23:44:48+00:00] FATAL: Could not load Moneta back end "BasicFile"
================================================================================
Error executing action `create` on resource 'template[/home/dan/.ssh/authorized_keys]'
================================================================================
LoadError
---------
cannot load such file -- moneta/basic_file
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/users/providers/manage.rb
88: template "#{home_dir}/.ssh/authorized_keys" do
89: source "authorized_keys.erb"
90: cookbook new_resource.cookbook
91: owner u['id']
92: group u['gid'] || u['id']
93: mode "0600"
94: variables :ssh_keys => u['ssh_keys']
95: end
96: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/users/providers/manage.rb:88:in `block (2 levels) in class_from_file'
template("/home/dan/.ssh/authorized_keys") do
provider Chef::Provider::Template
action "create"
retries 0
retry_delay 2
path "/home/dan/.ssh/authorized_keys"
backup 5
source "authorized_keys.erb"
cookbook "users"
variables {:ssh_keys=>"ssh-rsa <REPLACED BECAUSE SHUTUP>!"}
cookbook_name "users"
mode "0600"
owner "dan"
group "dan"
end
[2013-01-30T23:44:48+00:00] ERROR: Running exception handlers
[2013-01-30T23:44:48+00:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2013-01-30T23:44:48+00:00] ERROR: Exception handlers complete
[2013-01-30T23:44:48+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-01-30T23:44:48+00:00] FATAL: LoadError: template[/home/dan/.ssh/authorized_keys] (/var/chef/cache/cookbooks/users/providers/manage.rb line 88) had an error: LoadError: cannot load such file -- moneta/basic_file
I have no idea what is going on, what moneta is, or why it cannot build from that template. The template is in templates/default/authorized_keys.erb as expected.
It's the "moneta" gem, which was recently upgraded. Luckily, there is a simple fix (roll it back!), unless you are using new functionality inside that gem. Perform the following:
gem install moneta --version=0.6.0
gem uninstall moneta
... and then uninstall all versions of moneta >= 0.7.0
Reference chef ticket