From 2d66cb1903a8068496bf30a9348a7a2f2d43acb1 Mon Sep 17 00:00:00 2001 From: Jacek Tomasiak Date: Fri, 22 Sep 2017 13:14:31 +0200 Subject: [PATCH] provisioner: Make chef splay configurable For large installations this is useful to distribute the chef-server load caused by chef-clients. --- chef/cookbooks/provisioner/recipes/base.rb | 2 ++ .../provisioner/templates/default/chef_client.erb | 2 +- .../crowbar/migrate/provisioner/201_chef_splay.rb | 9 +++++++++ chef/data_bags/crowbar/template-provisioner.json | 3 ++- chef/data_bags/crowbar/template-provisioner.schema | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 chef/data_bags/crowbar/migrate/provisioner/201_chef_splay.rb diff --git a/chef/cookbooks/provisioner/recipes/base.rb b/chef/cookbooks/provisioner/recipes/base.rb index 0f04fc6806..2afbf2631c 100644 --- a/chef/cookbooks/provisioner/recipes/base.rb +++ b/chef/cookbooks/provisioner/recipes/base.rb @@ -211,6 +211,7 @@ config_file = "/etc/sysconfig/chef-client" chef_client_runs = node[:provisioner][:chef_client_runs] || 900 +chef_splay = node[:provisioner][:chef_splay] || 20 template config_file do owner "root" @@ -218,6 +219,7 @@ mode "0644" source "chef_client.erb" variables( + chef_splay: chef_splay, chef_client_runs: chef_client_runs ) notifies :restart, "service[chef-client]", :delayed diff --git a/chef/cookbooks/provisioner/templates/default/chef_client.erb b/chef/cookbooks/provisioner/templates/default/chef_client.erb index f54c6a4754..c1d99c0f21 100644 --- a/chef/cookbooks/provisioner/templates/default/chef_client.erb +++ b/chef/cookbooks/provisioner/templates/default/chef_client.erb @@ -1,4 +1,4 @@ LOGFILE=/var/log/chef/client.log CONFIG=/etc/chef/client.rb INTERVAL=<%= @chef_client_runs %> -SPLAY=20 +SPLAY=<%= @chef_splay %> diff --git a/chef/data_bags/crowbar/migrate/provisioner/201_chef_splay.rb b/chef/data_bags/crowbar/migrate/provisioner/201_chef_splay.rb new file mode 100644 index 0000000000..511a77a684 --- /dev/null +++ b/chef/data_bags/crowbar/migrate/provisioner/201_chef_splay.rb @@ -0,0 +1,9 @@ +def upgrade(ta, td, a, d) + a["chef_splay"] = ta["chef_splay"] unless a.key? "chef_splay" + return a, d +end + +def downgrade(ta, td, a, d) + a.delete("chef_splay") + return a, d +end diff --git a/chef/data_bags/crowbar/template-provisioner.json b/chef/data_bags/crowbar/template-provisioner.json index b177ecf7c7..b6f1d930e1 100644 --- a/chef/data_bags/crowbar/template-provisioner.json +++ b/chef/data_bags/crowbar/template-provisioner.json @@ -215,6 +215,7 @@ "debug": "debug" } }, + "chef_splay": 20, "chef_client_runs": 900 } }, @@ -222,7 +223,7 @@ "provisioner": { "crowbar-revision": 0, "crowbar-applied": false, - "schema-revision": 200, + "schema-revision": 201, "element_states": { "provisioner-server": [ "readying", "ready", "applying" ], "provisioner-base": [ "hardware-installing", "readying", "ready", "applying" ] diff --git a/chef/data_bags/crowbar/template-provisioner.schema b/chef/data_bags/crowbar/template-provisioner.schema index 49b96ccc8a..7d97fd03c6 100644 --- a/chef/data_bags/crowbar/template-provisioner.schema +++ b/chef/data_bags/crowbar/template-provisioner.schema @@ -104,6 +104,7 @@ } } }, + "chef_splay": { "type": "int", "required": true }, "chef_client_runs": { "type": "int", "required": true } } }