]> git.openstreetmap.org Git - chef.git/commitdiff
Install knife on the chef server and update paths
authorTom Hughes <tom@compton.nu>
Mon, 11 Oct 2021 09:05:37 +0000 (10:05 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 11 Oct 2021 09:16:02 +0000 (10:16 +0100)
cookbooks/chef/recipes/repository.rb
cookbooks/chef/recipes/server.rb
cookbooks/chef/templates/default/post-receive.erb
cookbooks/letsencrypt/files/default/bin/upload
cookbooks/letsencrypt/recipes/default.rb
cookbooks/munin/files/default/plugins/chef_status

index d5d8d2bc2817c6eeb759ca27f012672ea36fa193..cd0e868384a5ecf4d724f4674ba2155bf0d493f8 100644 (file)
@@ -25,6 +25,8 @@ chef_gem "bundler" do
   version ">= 2.1.4"
 end
 
+chef_gem "knife"
+
 directory "/var/lib/chef" do
   owner "chefrepo"
   group "chefrepo"
index cd4968b734c05452ff75d0d8058a8ac71b615d1c..c6ee6f7eb2afdac87e359a08d29a0766ae7bebec 100644 (file)
@@ -48,6 +48,8 @@ include_recipe "munin"
 #   notifies :run, "execute[chef-server-reconfigure]"
 # end
 
+chef_gem "knife"
+
 template "/etc/opscode/chef-server.rb" do
   source "server.rb.erb"
   owner "root"
index b402265c17fffff8be8219c27293490bc965a3dc..28ef5b4345874929661a8c46ff85dbc9e64de4d8 100644 (file)
@@ -5,6 +5,8 @@
 umask 0002
 unset GIT_DIR
 
+knife="/opt/chef/embedded/bin/knife"
+
 while read oldrev newrev refname
 do
   if [[ "$refname" = "refs/heads/master" ]]
@@ -25,17 +27,17 @@ do
       if [[ $file == roles/*.rb ]]
       then
         case "$action" in
-          A|M) knife role from file "${file}";;
-          D) knife role delete -y "${file:t:r}";;
+          A|M) $knife role from file "${file}";;
+          D) $knife role delete -y "${file:t:r}";;
         esac
       elif [[ $file == data_bags/*/*.json ]]
       then
         case "$action" in
           A|M) 
-            knife data bag create "${file:h:t}"
-            knife data bag from file "${file:h:t}" "${file:t}";;
+            $knife data bag create "${file:h:t}"
+            $knife data bag from file "${file:h:t}" "${file:t}";;
           D)
-            knife data bag delete -y "${file:h:t}" "${file:t:r}";;
+            $knife data bag delete -y "${file:h:t}" "${file:t:r}";;
         esac
       elif [[ $file == cookbooks/* ]]
       then
@@ -52,14 +54,14 @@ do
 
     if [[ -n "$updated_cookbooks" ]]
     then
-      knife cookbook upload "${(ou)updated_cookbooks[@]}"
+      $knife cookbook upload "${(ou)updated_cookbooks[@]}"
     fi
 
     if [[ -n "$deleted_cookbooks" ]]
     then
       for cookbook in "${(ou)deleted_cookbooks[@]}"
       do
-        knife cookbook delete -y "$cookbook"
+        $knife cookbook delete -y "$cookbook"
       done
     fi
   fi
index 56da6294c85dc13af95a75d9f390b45bf32c09db..a52f30257aea8764afbaae94012be5933a6bf19a 100755 (executable)
@@ -17,4 +17,4 @@ file = Tempfile.new(["letsencrypt", ".json"])
 file.puts JSON.generate(bag)
 file.close
 
-system("/usr/bin/knife", "data", "bag", "from", "file", "letsencrypt", file.path)
+system("/opt/chef/embedded/bin/knife", "data", "bag", "from", "file", "letsencrypt", file.path)
index a327119bf195974a2764a22490e9219111ace6e3..ed18254cc84c00b8bd07355311c0d960c822dd4a 100644 (file)
@@ -27,6 +27,8 @@ package %w[
   ruby
 ]
 
+chef_gem "knife"
+
 directory "/etc/letsencrypt" do
   owner "letsencrypt"
   group "letsencrypt"
index 9d4c742fc69acd30217134c9d940c986283a6096..6680c4aa06f25abacfd793b81fdd995be6a836bf 100755 (executable)
@@ -2,7 +2,7 @@
 
 require "json"
 
-nodes = JSON.parse(IO.popen(["knife", "status", "-c", "/var/lib/chef/.chef/knife.rb", "-F", "json"]).read).sort_by { |node| node["name"] }
+nodes = JSON.parse(IO.popen(["/opt/chef/embedded/bin/knife", "status", "-c", "/var/lib/chef/.chef/knife.rb", "-F", "json"]).read).sort_by { |node| node["name"] }
 
 if ARGV[0] == "config"
   puts "graph_title Chef node status"