Created
October 27, 2017 15:10
-
-
Save jblaine/a297b669eecdf745379071b1a0c07b0b to your computer and use it in GitHub Desktop.
FileUtils.mv being EXECUTED at compile time from a library method?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PART 1, THE EXCEPTION: | |
================================================================================ | |
Recipe Compile Error in /var/chef/cache/cookbooks/r701-apache/recipes/mcran-server.rb | |
================================================================================ | |
Errno::ENOENT | |
------------- | |
No such file or directory @ rb_file_s_rename - (/tmp/r701-apache-tmp-certs.pem, /etc/httpd/conf/../supporting_certs/certs.pem) | |
Cookbook Trace: | |
--------------- | |
/var/chef/cache/cookbooks/r701-apache/libraries/helpers.rb:69:in `cert_bundle_from_databag_items' | |
/var/chef/cache/cookbooks/r701-apache/libraries/helpers.rb:33:in `install_supporting_certs' | |
/var/chef/cache/cookbooks/r701-apache/recipes/mcran-server.rb:15:in `from_file' | |
Relevant File Content: | |
---------------------- | |
/var/chef/cache/cookbooks/r701-apache/libraries/helpers.rb: | |
68: | |
69>> FileUtils.mv("#{tmpdir}/#{tmpbundle}", node['r701-apache']['certificate_chain_file']) | |
70: return false | |
71: end | |
72: | |
# PART 2: THE RECIPE | |
install_supporting_certs | |
# END | |
# PART 3: THE LIBRARY METHODS (libraries/helpers.rb) | |
def supporting_certs_dir | |
return "#{node['r701-apache']['conf-dir']}/../supporting_certs" | |
end | |
def install_supporting_certs(bundle_filename='certs.pem', cert_ids=['ca-1', 'ca-3']) | |
directory supporting_certs_dir do | |
owner 'root' | |
group 'root' | |
mode '0755' | |
end | |
cert_bundle_from_databag_items(cert_ids) | |
end | |
def cert_bundle_from_databag_items(cert_ids) | |
tmpbundle = '/tmp/r701-apache-tmp-certs.pem' | |
if node['platform'] == 'windows' | |
tmpbundle = '/windows/temp/r701-apache-tmp-certs.pem' | |
end | |
::File.unlink(tmpbundle) if ::File.exist?(tmpbundle) | |
cert_ids.each do |id| | |
certdata = data_bag_item('supporting_certs', id)['certificate'] | |
::File.open(tmpbundle, 'a') { |file| file.write(certdata) } | |
end | |
FileUtils.mv(tmpbundle, node['r701-apache']['certificate_chain_file']) | |
end | |
# END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment