Skip to content

Commit 7dbd7e2

Browse files
committed
Set SSL_CERT_FILE
FWIW, after an upgrade to aws v2 I ran into ``` Seahorse::Client::Http::Error: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed ``` During a chef-client run on amazon linux and ubuntu, where I managed to make chef-client (and seahorse) happy again as follows: - `SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt chef-client` (ubuntu) - `SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt chef-client` (amazon linux) See https://www.happyassassin.net/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/, https://github.com/opscode-cookbooks/chef-client#attributes for more info.
1 parent b7076c3 commit 7dbd7e2

File tree

5 files changed

+52
-5
lines changed

5 files changed

+52
-5
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,12 @@ PASS=$(aws ec2 get-password-data --instance-id i-f67c0a35 --priv-launch-key $PWD
509509
knife winrm jenkins-worker-windows-publish chef-client -m -P $PASS
510510
```
511511

512-
- ubuntu: `ssh jenkins-worker-ubuntu-publish sudo chef-client`
513-
- amazon linux: `ssh jenkins-worker-behemoth-1`, and then `sudo chef-client`
512+
- linux
513+
```
514+
ssh jenkins-worker-ubuntu-publish
515+
sudo su --login # --login needed on ubuntu to set SSL_CERT_FILE (it's done in /etc/profile.d)
516+
chef-client
517+
```
514518

515519
### Attach eips
516520

metadata.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
license 'All rights reserved'
55
description 'Installs/Configures the Scala Jenkins infrastructure'
66
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7-
version '0.1.0'
7+
version '0.2.0'
88

99
# for chef_vault_item, which allows loading from plain databags when developing with vagrant
1010
depends 'chef-vault'
1111

12+
depends 'magic_shell'
13+
1214
depends 'chef-client'
1315
depends 'cron'
1416

recipes/_init-chef-client.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Cookbook Name:: scala-jenkins-infra
3+
# Recipe:: _init-chef-client
4+
#
5+
# Copyright 2015, Typesafe, Inc.
6+
#
7+
# All rights reserved - Do Not Redistribute
8+
#
9+
10+
# location is platform dependent (ubuntu/amazon/window)
11+
sslCertFile = ['/etc/ssl/certs/ca-certificates.crt', '/etc/ssl/certs/ca-bundle.crt', 'c:\opscode\chef\embedded\ssl\certs\cacert.pem'].find{|p| File.exist?(p)}
12+
13+
# for good measure, in case magic_shell_environment's modifications don't make it to the shell used by cron...
14+
if sslCertFile != nil
15+
node.set['chef_client']['cron']['environment_variables']="SSL_CERT_FILE=#{sslCertFile}"
16+
end
17+
18+
# set SSL_CERT_FILE so that ruby's openssl can connect to aws etc... URGH
19+
# NOTE will need a reboot....
20+
case node["platform_family"]
21+
when "windows"
22+
env "SSL_CERT_FILE" do
23+
value sslCertFile
24+
only_if {sslCertFile != nil}
25+
end
26+
else
27+
magic_shell_environment 'SSL_CERT_FILE' do
28+
value sslCertFile
29+
only_if {sslCertFile != nil}
30+
end
31+
end
32+
33+
# has no effect!?
34+
# ruby_block 'Set SSL_CERT_FILE' do
35+
# block do
36+
# ENV['SSL_CERT_FILE'] = sslCertFile
37+
# end
38+
# only_if {sslCertFile != nil}
39+
# end
40+
41+
include_recipe 'chef-client::service'

recipes/master-init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# All rights reserved - Do Not Redistribute
88
#
9-
include_recipe 'chef-client::service'
9+
include_recipe 'scala-jenkins-infra::_init-chef-client'
1010

1111
include_recipe "java"
1212

recipes/worker-init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# All rights reserved - Do Not Redistribute
88
#
9-
include_recipe 'chef-client::service' # TODO: it seems chef's not run on boot on windows?
9+
include_recipe 'scala-jenkins-infra::_init-chef-client'
1010

1111
include_recipe "aws"
1212

0 commit comments

Comments
 (0)