X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/18b7b58050667876d0456cbdd3835fdd96de0bc8..864d5dd378e3abaceec0119861696aa99f5d5628:/cookbooks/networking/recipes/default.rb?ds=inline diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 013037959..6648998f0 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -177,17 +177,15 @@ package "cloud-init" do action :purge end -execute "hostname" do +ohai "reload-hostname" do action :nothing - command "/bin/hostname -F /etc/hostname" + plugin "hostname" end -template "/etc/hostname" do - source "hostname.erb" - owner "root" - group "root" - mode 0o644 - notifies :run, "execute[hostname]" +execute "hostnamectl-set-hostname" do + command "hostnamectl set-hostname #{node[:networking][:hostname]}" + notifies :reload, "ohai[reload-hostname]" + not_if { ENV.key?("TEST_KITCHEN") || node[:hostnamectl][:static_hostname] == node[:networking][:hostname] } end template "/etc/hosts" do @@ -195,6 +193,7 @@ template "/etc/hosts" do owner "root" group "root" mode 0o644 + not_if { ENV["TEST_KITCHEN"] } end service "systemd-resolved" do