Created
May 29, 2015 00:18
-
-
Save jblaine/47f6191a084d319639e4 to your computer and use it in GitHub Desktop.
Intermediary SSL device certificate installation for chef_gem to even work
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
# | |
# Intermediary SSL device (sniffer/decrypter) certificate | |
# installation on Windows (w/o Cygwin) for chef_gem to even | |
# talk to https://rubygems.org from inside $WORK | |
# | |
# FML | |
# | |
node['our-certs']['filenames'].each do |cert| | |
cookbook_file cert do | |
blah blah put file in Chef::Config[:file_cache_path] | |
end | |
execute "Append #{cert} to embedded Chef omnibus cacert.pem" do | |
only_if { platform?('windows') } | |
# Mimics "test" from UNIX/Linux | |
only_if "if exist C:\\opscode\\chef\\embedded\\ssl\\certs true" | |
# Idempotence implementation: This needs explaining, so... | |
# There's no "head" or "tail" for Windows without invoking Powershell. | |
# In order to keep from hardcoding a piece of the certificate into this | |
# recipe to do an idempotence "grep" check, we extract the truly unique infor- | |
# mation from the certificate ( by removing the BEGIN / END lines) and write | |
# it to a temporary file. We then search for those lines in the Omnibus | |
# cacert.pem file. If they're found, we don't execute. See FINDSTR /? for | |
# further info. | |
not_if "findstr /V CERTIFICATE #{Chef::Config[:file_cache_path]}\\#{cert} > #{Chef::Config[:file_cache_path]}\\foo & findstr /G:#{Chef::Config[:file_cache_path]}\\foo C:\\opscode\\chef\\embedded\\ssl\\certs\\cacert.pem > nul" | |
command "type #{Chef::Config[:file_cache_path]}\\#{cert} >> C:\\opscode\\chef\\embedded\\ssl\\certs\\cacert.pem" | |
end.run_action(:run) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment