diff options
author | Marc Chamberland <mchamberland@pbsc.com> | 2019-06-03 22:15:16 -0400 |
---|---|---|
committer | Marc Chamberland <mchamberland@pbsc.com> | 2019-06-03 23:05:49 -0400 |
commit | 7eda1e5bf3f71c00bd08bde20a03b817caf95095 (patch) | |
tree | 0c6ea467b4e4af4acbadf7ab777a7ef4bd19cb8e /lib/chef/knife | |
parent | 8ab574c75ada5112b89149cc63b3a4f007664974 (diff) | |
download | chef-7eda1e5bf3f71c00bd08bde20a03b817caf95095.tar.gz |
more distro constants
Signed-off-by: Marc Chamberland <mchamberland@pbsc.com>
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/bootstrap/templates/chef-full.erb | 26 | ||||
-rw-r--r-- | lib/chef/knife/configure.rb | 3 | ||||
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 10 |
3 files changed, 20 insertions, 19 deletions
diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/lib/chef/knife/bootstrap/templates/chef-full.erb index 9f2e96ba84..f70a94ea55 100644 --- a/lib/chef/knife/bootstrap/templates/chef-full.erb +++ b/lib/chef/knife/bootstrap/templates/chef-full.erb @@ -186,55 +186,55 @@ if test "x$tmp_dir" != "x"; then rm -r "$tmp_dir" fi -mkdir -p /etc/chef +mkdir -p <%= Chef::Dist::CONF_DIR %> <% if client_pem -%> -cat > /etc/chef/client.pem <<'EOP' +cat > <%= Chef::Dist::CONF_DIR %>/client.pem <<'EOP' <%= ::File.read(::File.expand_path(client_pem)) %> EOP -chmod 0600 /etc/chef/client.pem +chmod 0600 <%= Chef::Dist::CONF_DIR %>/client.pem <% end -%> <% if validation_key -%> -cat > /etc/chef/validation.pem <<'EOP' +cat > <%= Chef::Dist::CONF_DIR %>/validation.pem <<'EOP' <%= validation_key %> EOP -chmod 0600 /etc/chef/validation.pem +chmod 0600 <%= Chef::Dist::CONF_DIR %>/validation.pem <% end -%> <% if encrypted_data_bag_secret -%> -cat > /etc/chef/encrypted_data_bag_secret <<'EOP' +cat > <%= Chef::Dist::CONF_DIR %>/encrypted_data_bag_secret <<'EOP' <%= encrypted_data_bag_secret %> EOP -chmod 0600 /etc/chef/encrypted_data_bag_secret +chmod 0600 <%= Chef::Dist::CONF_DIR %>/encrypted_data_bag_secret <% end -%> <% unless trusted_certs.empty? -%> -mkdir -p /etc/chef/trusted_certs +mkdir -p <%= Chef::Dist::CONF_DIR %>/trusted_certs <%= trusted_certs %> <% end -%> <%# Generate Ohai Hints -%> <% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%> -mkdir -p /etc/chef/ohai/hints +mkdir -p <%= Chef::Dist::CONF_DIR %>/ohai/hints <% @chef_config[:knife][:hints].each do |name, hash| -%> -cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP' +cat > <%= Chef::Dist::CONF_DIR %>/ohai/hints/<%= name %>.json <<'EOP' <%= Chef::JSONCompat.to_json(hash) %> EOP <% end -%> <% end -%> -cat > /etc/chef/client.rb <<'EOP' +cat > <%= Chef::Dist::CONF_DIR %>/client.rb <<'EOP' <%= config_content %> EOP -cat > /etc/chef/first-boot.json <<'EOP' +cat > <%= Chef::Dist::CONF_DIR %>/first-boot.json <<'EOP' <%= Chef::JSONCompat.to_json(first_boot) %> EOP <% unless client_d.empty? -%> -mkdir -p /etc/chef/client.d +mkdir -p <%= Chef::Dist::CONF_DIR %>/client.d <%= client_d %> <% end -%> diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb index 5ff5d96aa0..739428d5e3 100644 --- a/lib/chef/knife/configure.rb +++ b/lib/chef/knife/configure.rb @@ -18,6 +18,7 @@ require_relative "../knife" require_relative "../util/path_helper" +require_relative "../dist" class Chef class Knife @@ -116,7 +117,7 @@ class Chef if config[:initial] @new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", default: Etc.getlogin) @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", default: "admin") - @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", default: "/etc/chef-server/admin.pem") + @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", default: "#{Chef::Dist::SERVER_CONF_DIR}/admin.pem") @admin_client_key = File.expand_path(@admin_client_key) else @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", default: Etc.getlogin) diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 997ebd5f28..fbe56031cb 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -158,11 +158,11 @@ class Chef end if encrypted_data_bag_secret - client_rb << %Q{encrypted_data_bag_secret "/etc/chef/encrypted_data_bag_secret"\n} + client_rb << %Q{encrypted_data_bag_secret "#{Chef::Dist::CONF_DIR}/encrypted_data_bag_secret"\n} end unless trusted_certs.empty? - client_rb << %Q{trusted_certs_dir "/etc/chef/trusted_certs"\n} + client_rb << %Q{trusted_certs_dir "#{Chef::Dist::CONF_DIR}/trusted_certs"\n} end if Chef::Config[:fips] @@ -175,7 +175,7 @@ class Chef def start_chef # If the user doesn't have a client path configure, let bash use the PATH for what it was designed for client_path = @chef_config[:chef_client_path] || "#{Chef::Dist::CLIENT}" - s = "#{client_path} -j /etc/chef/first-boot.json" + s = "#{client_path} -j #{Chef::Dist::CONF_DIR}/first-boot.json" if @config[:verbosity] && @config[:verbosity] >= 3 s << " -l trace" elsif @config[:verbosity] && @config[:verbosity] >= 2 @@ -226,7 +226,7 @@ class Chef content = "" if @chef_config[:trusted_certs_dir] Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(@chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert| - content << "cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\n" + + content << "cat > #{Chef::Dist::CONF_DIR}/trusted_certs/#{File.basename(cert)} <<'EOP'\n" + IO.read(File.expand_path(cert)) + "\nEOP\n" end end @@ -240,7 +240,7 @@ class Chef root.find do |f| relative = f.relative_path_from(root) if f != root - file_on_node = "/etc/chef/client.d/#{relative}" + file_on_node = "#{Chef::Dist::CONF_DIR}/client.d/#{relative}" if f.directory? content << "mkdir #{file_on_node}\n" else |