3ofcoins / chef-cookbook-hostname

Chef cookbook to set node's hostname and FQDN.
MIT License
41 stars 90 forks source link

Support for distors with systemd #54

Open ljesmin opened 8 years ago

ljesmin commented 8 years ago

Centos 7 and other distros with Systemd do not can manage hostname with hostnamectl command.

I am using quite simple solution,

      execute "hostnamectl set-hostname" do
        command "hostnamectl set-hostname #{fqdn}"
        action :run
        only_if { node['fqdn'] != fqdn }
        notifies :reload, 'ohai[reload_hostname]', :immediately
      end