Skip to content
Chef cookbook to set node's hostname and FQDN.
Branch: develop
Clone or download
Latest commit d2e0534 May 5, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
recipes Merge pull request #52 from msilvey/develop Apr 24, 2017
spec Fix spec failures due to undefined local variable or method 'chef_run' Apr 24, 2017
.rspec Update ChefSpec testing Sep 7, 2016
.travis.yml Use TravisCI container infrastructure Sep 7, 2016
Berksfile rubocop lint fix Aug 27, 2015 Update May 5, 2017
LICENSE fixing conflicts Nov 5, 2015

hostname cookbook

Build Status Chef cookbook


Sets hostname and FQDN of the node. The latest code is hosted at


Setting hostname on FQDN is not (and won't be) supported. Unfortunately, using dots in the hostname can cause inconsistent results for any system that consumes DNS and is not allowed by RFC952. If a user needs additional info in their shell prompt, they can change PS1 in etc/profile to include the FQDN together with any information they find useful (such as the customer, the environment, etc).


  • node['set_fqdn'] - FQDN to set.

The asterisk character will be replaced with This way, you can add this to base role:

default_attributes :set_fqdn => '*'

and have node set its FQDN and hostname based on its chef node name (which is provided on chef-client first run's command line).

  • node['hostname_cookbook']['hostsfile_ip'] -- IP used in /etc/hosts to correctly set FQDN (default:

  • node['hostname_cookbook']['hostsfile_aliases'] -- list of aliases used in /etc/hosts for the ip set above (default: [hostname])

  • node['hostname_cookbook']['hostsfile_include_hostname_in_aliases'] -- whether to include the hostname at the end of the aliases list above (default: true)

  • node['hostname_cookbook']['append_hostsfile_ip'] -- Set to false to prevent an entry for the node's hostname from being appended in /etc/hosts (default: true)


  • hostname::default -- will set node's FQDN to value of set_fqdn attribute, and hostname to its host part (up to first dot).
  • hostname::vmware -- sets hostname automatically using vmtoolsd. You do not need to set node["set_fqdn"].


Author: Maciej Pasternacki

You can’t perform that action at this time.