From 4e25113d66b5ae4a4fbedb7046bced6aee5eee22 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 29 Apr 2020 22:53:53 +0100 Subject: [PATCH] Give up on the hostname resource and do it ourselves --- cookbooks/networking/recipes/default.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 4e496439b..03c7461a4 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -177,8 +177,15 @@ package "cloud-init" do action :purge end -hostname node[:networking][:hostname] do - ipaddress nil +ohai "reload-hostname" do + action :nothing + plugin "hostname" +end + +execute "hostnamectl-set-static" do + command "hostnamectl set-static #{node[:networking][:hostname]}" + notifies :reload, "ohai[reload-hostname]" + not_if { node[:hostnamectl][:static_hostname] == node[:networking][:hostname] } end template "/etc/hosts" do -- 2.39.5