]> git.openstreetmap.org Git - chef.git/commitdiff
Give up on the hostname resource and do it ourselves
authorTom Hughes <tom@compton.nu>
Wed, 29 Apr 2020 21:53:53 +0000 (22:53 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 29 Apr 2020 21:53:53 +0000 (22:53 +0100)
cookbooks/networking/recipes/default.rb

index 4e496439bf99642e7b295618e1e7825cc935a4e4..03c7461a4253419ffcdb4a9efcd0c1addbe45a5e 100644 (file)
@@ -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