]> git.openstreetmap.org Git - chef.git/commitdiff
Make sure the Passwd ohai plugin is enabled
authorTom Hughes <tom@compton.nu>
Wed, 12 Feb 2020 19:04:35 +0000 (19:04 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 12 Feb 2020 19:15:22 +0000 (19:15 +0000)
This plugin becomes optional in chef 15 so make sure it is
enabled, and cope during the first pass on a new node when
it is not enabled yet.

cookbooks/accounts/recipes/default.rb
cookbooks/chef/templates/default/client.rb.erb

index 7eb760f3cc7c8c2990903d81356e39e922f5b4a5..250ca9e410a136b406a6c84848109b849d9a0032 100644 (file)
@@ -39,9 +39,15 @@ search(:accounts, "*:*").each do |account|
       user_shell = details[:shell] || account["shell"] || node[:accounts][:shell]
     end
 
+    available_users = if node[:etc]
+                        node[:etc][:passwd].keys
+                      else
+                        []
+                      end
+
     group name.to_s do
       gid account["uid"].to_i
-      members group_members & node[:etc][:passwd].keys
+      members group_members & available_users
     end
 
     user name.to_s do
index 5d1f463930de23870f0273116e749d3218690e62..094340f160d8967ac47dbfec386ed16bcc822181 100644 (file)
@@ -33,6 +33,10 @@ chef_server_url "https://chef.openstreetmap.org/organizations/openstreetmap"
 
 ohai.plugin_path << "<%= node[:ohai][:plugin_dir] %>"
 
+# Enable some optional ohai plugins
+
+ohai.optional_plugins = %w[Passwd]
+
 # Load supporting code for report handlers
 
 require "/etc/chef/report"