-
Notifications
You must be signed in to change notification settings - Fork 0
/
knife.rb
44 lines (34 loc) · 1.18 KB
/
knife.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'dotenv'
::Dotenv.load
local_mode true
chef_repo_path __dir__
knife[:ssh_attribute] = 'knife_zero.host'
knife[:use_sudo] = true
knife[:automatic_attribute_whitelist] = %w[
fqdn
]
knife[:default_attribute_whitelist] = []
knife[:normal_attribute_whitelist] = %w[
knife_zero
test
]
knife[:override_attribute_whitelist] = []
berkshelf_vendor_cmd = 'bundle exec berks vendor cookbooks'
knife[:before_bootstrap] = berkshelf_vendor_cmd
knife[:before_converge] = berkshelf_vendor_cmd
environment = ::ENV['KNIFE_NODE_ENVIRONMENT'] || ::ENV.fetch('KNIFE_NODE_DEFAULT_ENVIRONMENT', nil)
if environment.nil?
raise 'Unspecified default environment!'
end
secret_file = ::ENV.fetch("KNIFE_NODE_SECRET_FILE_#{environment.upcase}", nil)
ignore_secret_file = ::ENV.fetch("KNIFE_NODE_IGNORE_SECRET_FILE_#{environment.upcase}", 'no') == 'yes'
unless ignore_secret_file
secret_file = ::File.expand_path(secret_file)
if !secret_file.nil? && ::File.exist?(secret_file)
knife[:secret_file] = secret_file
else
raise 'Couldn\'t find any encrypted data bag secret for environment'\
" <#{environment}>!"
end
end
config_log_level ::ENV.fetch('KNIFE_NODE_LOG_LEVEL', 'warn').to_sym