On some of the networks that we will be provisioning the software/configuration of our applications they are closed and do not have access to the internet. Additionally, all our clients have different networks, drive layouts and so on, so there is no central location that we can use to obtain the installer packages, such as jdk-8u172-windows-x64.exe for installing Java 8 on Windows.
To get around this, I would like to put the exe/msi files within the cookbook and reference them directly. I thought I found a way to do this by putting the exe in an assets
folder under the cookbook and referencing the files inside that folder, but it doesn't appear to be enough.
jdk_package = 'jdk-8u172-windows-x64.exe'
jdk_identifier = File.basename( jdk_package, File.extname( jdk_package ) )
jdk_package_installer = File.join( Chef::Config[:file_cache_path], 'cookbooks', cookbook_name, 'assets', jdk_package )
java_attr = node['myapp']['java']
jdk_home = java_attr['jdk_home']
jre_home = java_attr['jre_home']
jdk_package_install_log = java_attr['install_log']
jdk_package_options = "/s ADDLOCAL=\"ToolsFeature,SourceFeature,PublicjreFeature\" INSTALLDIR=\"#{jdk_home}\" /INSTALLDIRPUBJRE=\"#{jre_home}\" /L \"#{jdk_package_install_log}\""
jdk_java_executable = File.expand_path( File.join('bin', 'java.exe'), jdk_home )
jre_java_executable = File.expand_path( File.join('bin', 'java.exe'), jre_home )
windows_package jdk_identifier do
source jdk_package_installer
options jdk_package_options
installer_type :custom
action :install
end
Unfortunately, when it runs I get a problem as the exe file cannot be found.
mynode.local * windows_package[jdk-8u172-windows-x64] action install[2018-09-13T18:28:00+01:00] INFO: Processing windows_package[jdk-8u172-windows-x64] action install (oracle_java8::default line 35)
mynode.local
mynode.local * Source for package jdk-8u172-windows-x64 does not exist
mynode.local ================================================================================
mynode.local Error executing action `install` on resource 'windows_package[jdk-8u172-windows-x64]'
mynode.local ================================================================================
mynode.local
mynode.local Chef::Exceptions::Package
mynode.local -------------------------
mynode.local Source for package jdk-8u172-windows-x64 does not exist
mynode.local
mynode.local Resource Declaration:
mynode.local ---------------------
mynode.local # In c:/chef/cache/cookbooks/oracle_java8/recipes/default.rb
mynode.local
mynode.local 35: windows_package jdk_identifier do
mynode.local 36: source jdk_package_installer
mynode.local 37: options jdk_package_options
mynode.local 38: installer_type :custom
mynode.local 39: action :install
mynode.local 40: end
mynode.local
mynode.local Compiled Resource:
mynode.local ------------------
mynode.local # Declared in c:/chef/cache/cookbooks/oracle_java8/recipes/default.rb:35:in `from_file'
mynode.local
mynode.local windows_package("jdk-8u172-windows-x64") do
mynode.local package_name "jdk-8u172-windows-x64"
mynode.local action [:install]
mynode.local default_guard_interpreter :default
mynode.local declared_type :windows_package
mynode.local cookbook_name "oracle_java8"
mynode.local recipe_name "default"
mynode.local source "c:\\chef\\cache\\cookbooks\\oracle_java8\\assets\\jdk-8u172-windows-x64.exe"
mynode.local options "/s ADDLOCAL=\"ToolsFeature,SourceFeature,PublicjreFeature\" INSTALLDIR=\"D:/OT/jdk8\" /INSTALLDIRPUBJRE=\"D:/OT/jre8\" /L \"D:/OT/chef_install-oracle_java8.log\""
mynode.local installer_type :custom
mynode.local end
mynode.local
mynode.local System Info:
mynode.local ------------
mynode.local chef_version=14.4.56
mynode.local platform=windows
mynode.local platform_version=10.0.14393
mynode.local ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]
mynode.local program_name=C:/opscode/chef/bin/chef-client
mynode.local executable=C:/opscode/chef/bin/chef-client
mynode.local
mynode.local [2018-09-13T18:28:00+01:00] INFO: Running queued delayed notifications before re-raising exception
mynode.local
mynode.local Running handlers:
mynode.local [2018-09-13T18:28:00+01:00] ERROR: Running exception handlers
mynode.local Running handlers complete
mynode.local [2018-09-13T18:28:00+01:00] ERROR: Exception handlers complete
mynode.local Chef Client failed. 12 resources updated in 06 seconds
mynode.local [2018-09-13T18:28:00+01:00] INFO: Sending resource update report (run-id: ce69a476-b437-4462-bb18-c50659326e40)
mynode.local [2018-09-13T18:28:00+01:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
mynode.local [2018-09-13T18:28:00+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
mynode.local [2018-09-13T18:28:00+01:00] FATAL: Chef::Exceptions::Package: windows_package[jdk-8u172-windows-x64] (oracle_java8::default line 35) had an error: Chef::Exceptions::Package: Source for package jdk-8u172-windows-x64 does not exist
ERROR: Failed to execute command on mynode.local return code 1
I presume this is to do with the way Chef lazy loads files.
Is there a way to force Chef to load it or a better way to package the installers within cookbooks?