Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status


system (24) Versions 0.11.2

Installs/Configures system elements such as the hostname and timezone.

cookbook 'system', '= 0.11.2', :supermarket
cookbook 'system', '= 0.11.2'
knife supermarket install system
knife supermarket download system
Quality 57%

system Cookbook

Cookbook Version
Dependency Status
Code Climate
Test Coverage
Join the chat at

Build Status

Travis CI
Master Build status
Latest Release (0.11.2) Build status


This cookbook is designed to provide a set of recipes and LWRPs for managing the core properties of a host's system.

Currently the main features (from a high level) include:
- setting the hostname/domain name
- setting the default NetBIOS name and Workgroup (OS X only)
- setting the timezone
- configuring the system-wide profile (/etc/profile)
- managing packages (install, uninstall & upgrade)

Ad-hoc style operational tasks such as reboot and shutdown are also implemented by recipes.

Get it now from your (local) supermarket!


  • Chef >= 11.12.0
  • Ruby >= 1.9

Platforms Supported

  • Debian, Ubuntu
  • CentOS, RHEL, Fedora
  • Arch Linux
  • FreeBSD
  • Mac OS X


  • apt
  • cron
  • hostsfile


See attributes/default.rb for default values.

  • node['system']['timezone'] - the system timezone to set, default Etc/UTC
  • node['system']['short_hostname'] - the short hostname to set on the node, default is node['hostname']
  • node['system']['domain_name'] - the domain name to set on the node, default localdomain
  • node['system']['netbios_name'] - the NetBIOS name to set on the node, default is node['system']['short_hostname'] upper-cased (OS X only)
  • node['system']['workgroup'] - the NetBIOS workgroup name to set on the node, default is WORKGROUP (OS X only)
  • node['system']['static_hosts'] - a hash of static hosts to add to /etc/hosts
  • node['system']['upgrade_packages'] - whether to upgrade the system's packages, default true
  • node['system']['upgrade_packages_at_compile'] - whether upgrade of the system's packages in Chef's compilation phase, default true
  • node['system']['enable_cron'] - whether to include the cron recipe, default true
  • node['system']['packages']['install'] - an array of packages to install (also supports remote package URLs)
  • node['system']['packages']['install_compile_time'] - an array of packages to install in Chef's compilation phase (also supports remote package URLs)
  • node['system']['manage_hostsfile'] - whether or not to manage /etc/hostsfile (in any way)
  • node['system']['permanent_ip'] - whether the system has a permenent IP address (
  • node['system']['primary_interface'] - Specify primary network interface, used by hostname to set the correct address in hostsfile, default is node['network']['default_interface']
  • node['system']['delay_network_restart'] - whether to trigger restart event as delayed. false causes an immediate restart instead. default true

Attributes (all arrays) to manipulate the system-wide profile (usually for /etc/profile):

  • node['system']['profile']['path'] - override the default PATH for the system
  • node['system']['profile']['path_append'] - append more paths to the base path
  • node['system']['profile']['path_prepend'] - prepend more paths to the base path
  • node['system']['profile']['append_scripts'] - an array of shell scripts to be appended to the system profile (include raw scripts without shebangs)




Includes the system::update_package_list, system::timezone and system::hostname recipes only.

NOTE: if applicable, the system's package manager's package list will be updated, but installed packages won't be upgraded. To upgrade the system's packages, include the system::upgrade_packages recipe in your run_list or role.


When using resources that reference node['fqdn'] in variables or attribute values, note that you will
need to lazy load to get the new hostname that is being set.

Use with variables:

template '/tmp/foobar.txt' do
source 'use_fqdn_in_variable.erb'
variables lazy {
fqdn: node['fqdn'],
foo: bar

Use with a resource attribute:

log 'lazy_log_fqdn' do
message lazy { node['fqdn'] }
level :debug


Manages /etc/profile with optional shell scripts to append from node['system']['profile']['append_scripts'],
configure PATH requirements per attributes documented above.


Installs a list of system packages as specified in the node['system']['packages']['install'] attribute.
Will also install packages provided at compile time from within node['system']['packages']['install_compile_time'].


Uninstalls a list of system packages as specified in the node['system']['packages']['uninstall'] attribute.
Will also uninstall packages provided at compile time from within node['system']['packages']['uninstall_compile_time'].


Attempts to gracefully reboot the operating system.


Attempts to gracefully shutdown the operating system.


Sets the timezone of the system.


Updates the local package manager's package list.


Upgrades all installed packages of the local package manager.


The cookbook currently provides 3 Lightweight Resource Providers that can be used in your own recipes
by depending on this cookbook. Recipes are provided interfacing each of these for convenience but
you may find them useful in your own cookbook usage.


Attribute Description Example Default
short_hostname The short hostname for the system starbug nil
domain_name The domain name for the system nil
static_hosts An array of static hosts to add to /etc/hosts [{ '' => '' }, { '' => '' }] nil

Set the hostname providing the desired FQDN:

system_hostname ''

Providing the short hostname as the resource name and explicitly defining the domain name
(alas this is a bit verbose), as well as some static hosts:

system_hostname 'starbug' do
short_hostname 'starbug'
domain_name ''
static_hosts(({ '' => '',
'' => '' }))

The system::hostname recipe implements it this way as short_hostname and domain_name
are the exposed cookbook attributes.


Attribute Description Example Default
timezone The timezone to set the system to Australia/Sydney Etc/UTC
system_timezone 'Australia/Sydney'


Attribute Description Example Default
packages The timezone to set the system to %w(wget curl) []
phase The Chef phase to download the packages in :compile :converge
system_packages %w(wget curl).join(',') do
  packages %w(wget curl)
  phase :compile


Attribute Description Example Default
filename The system profile file to manage /etc/profile /etc/profile
template The cookbook erb template for the profile file custom_profile.erb profile.erb
path An environment search path to prepend to the default /opt/local/bin []
append_scripts Arbitrary scripts to append to the profile ['export FOO=bar'] nil
system_profile '/etc/profile' do
  path ['/opt/local/bin', '/opt/foo/bin']
  append_scripts ['export FOO=bar']

Publish to Chef Supermarket

$ cd ..
$ knife cookbook site share system "Operating Systems & Virtualization" -o . -u xhost -k ~/.chef/xhost.pem

License and Authors

Copyright 2011-2016, Chris Fordham

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.


This file is used to list changes made in each version of the system cookbook.


  • Initial pre-release version


  • Initial 'pre 1' minor release


  • Includes bug fixes, revised code and more testing files


  • Fix missing quote for rs_tag command in hostname provider


  • Fix missing equals sign for service_action variable
  • Fix notifies for service[hostname] for Debian
  • Set on Debian if needed
  • Fix for OHAI-389
  • Set supports status false for hostname service
  • Use service_name for hostname resource name
  • Minor log text improvements for show host info
  • Notify the hostname service immediately.
  • Address FC037: Invalid notification action
  • Add chefignore
  • Add




  • Better platform support for default cron service
  • timezone provider ensures inclusion of cron recipe
  • Other minor fixes for cron
  • Improve test suite, add basic tests
  • Add a recipe to test setting of the fqdn
  • New attribute, permanent_ip to affect usage of on debian
  • Fix setting hosts in /etc/hosts by using lazy loading of fqdn
  • Set fqdn in compile phase, to be sure



  • Add a hostsfile entry for against localhost.localdomain when not using permanent_ip
  • Include the FQDN in the hostfile entry for for when not on Debian
  • Add resource for the network service in RHEL platform family (restart it on hostname change)
  • Use Chef::Util::FileEdit instead of sed to update /etc/sysconfig/network
  • permanent_ip is now true by default
  • Add support for hostnamectl (mostly for EL 7)
  • Fix missing trailing line return for /etc/hostname
  • Test Debian and CentOS with test-kitchen


  • Mac OS X support (including NetBIOS and Workgroup names)!
  • Pull request #11 (default timezone is now 'Etc/UTC')
  • Fail when an invalid timezone is provided
  • Support providing a zone with a space instead of underscore (for the humans)
  • Make before and after tz-info log resources debug log level
  • update_package_list recipe will now sync MacPorts tree
  • upgrade_packages recipe will now upgrade installed ports for MacPorts
  • Improved test suite including use of chef_zero with test-kitchen, more platforms/versions
  • Add a good handful of Serverspec tests


  • Ensure the crond service is available for restarting in timezone provider
  • Add mac_os_x to supports in metadata


  • Fix cron daemon usage for arch linux (uses cronie which is not yet supported in the cron cookbook yet)
  • Fix cron_service_name for arch linux (cronie) in default attributes
  • Fix supports for arch linux in metadata.rb


  • Use regex with readlines grep when checking for hostname in /etc/sysconfig/network on EL-based distros (fix for issue #14)
  • Help bad images/systems that have a null hostname (fix for issue #15)


  • Fix for issue #17 removing unique hostfile entry for
  • Fix render of static_hosts via node attributes
  • Add hostfile entries for ipv6 hosts
  • Let the cron cookbook manage the cron resources entirely
  • Various test elements added/improved


  • New system_packages LWRP
  • Support for installing remote packages by URL using the system_packages LWRP
  • timezone provider now defaults to Etc/UTC timezone


  • Initial FreeBSD support
  • Manage /etc/profile by recipe or system_profile LWRP
  • system::hostname recipe parameterizes available provider attributes
  • Support for using the name_attribute of the hostname resource for fqdn
  • Fix for issue #22 (timezone set idempotency)
  • Various minor fixes


  • Manage /etc/environment by recipe or system_environment LWRP
  • Support optional management of /etc/hosts (e.g. do not add hostname to this file)
  • Support optional inclusion of the cron recipe
  • Use ohai to determine network IP (pr #26)
  • Allow specification primary network interface for hostsfile generation (pr #26)
  • Improve/fix templating for system profile (/etc/profile)


  • Fix missing end statement in templates/arch/profile.erb


  • Make it possible to control which phase package upgrades occur (issue #28)
  • More lazy string from bool support for attributes in RightScale
  • Support for Ubuntu 15.04 (issue #30 and #31)
  • Chef 13 forward compliance (Do not specify both default and name_property together on property filename of resource)
  • Better docker support and with test-kitchen (.kitchen-docker.yml)
  • Add a Dockerfile
  • timedatectl for supported systems (issue #32)
  • Support path_append and path_prepend (issue #27)


  • Fix missing underscore in ip_address attribute for hostsfile entry
  • Fix logic on if the cron service should be notified or used within timezone provider resources


  • Fix cookbook templates attempting to use incorrect cookbook templates (pr #40)
  • Raspbian platform support (pr #41)
  • Add ChefSpec matchers (pr #42)
  • Refresh (issue #39)
  • /etc/hostname should be short hostname and mode 0644 (issue #37)
  • Do not include any comment lines in /etc/hostname out of safeness
  • Remove temporary archlinux code for cron (timezone provider)
  • Only set hostsfile entry if private IP is set (issue #35)
  • Network restart control feature (pr #36)
  • Make attribute de-reference safe for failing attributes when undefined (pr #34)
  • Test Kitchen path fix for docker (issue #33)
  • Various test related improvements, bumps, fixes


Fix release to address issue #47 where hostname does not persist after reboot.

  • always set HOSTNAME in /etc/sysconfig/network if the config file exists
  • do not run domainname if the domainname is already as desired
  • configure preserve_hostname with cloud-init if cloud-init is installed
  • update hostname with nmcli if installed
  • restart systemd-hostnamed if enabled


Fix release to address issue #49 where an only_if attribute causes a fatal error

  • check for that systemctl command exists first with type command
  • fix expectation of hostname command returning FQDN in serverspec
  • ubuntu 16.04 now tested with test-kitchen

Collaborator Number Metric

0.11.2 failed this metric

Failure: Cookbook has 1 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric

0.11.2 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of, and your repo must contain a file

Foodcritic Metric

0.11.2 failed this metric

FC066: Ensure chef_version is set in metadata: system/metadata.rb:1
FC069: Ensure standardized license defined in metadata: system/metadata.rb:1
FC072: Metadata should not contain "attribute" keyword: system/metadata.rb:1
FC074: LWRP should use DSL to define resource's default action: system/resources/hostname.rb:1
FC074: LWRP should use DSL to define resource's default action: system/resources/packages.rb:1
FC074: LWRP should use DSL to define resource's default action: system/resources/timezone.rb:1
Run with Foodcritic Version 11.1.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

License Metric

0.11.2 passed this metric

No Binaries Metric

0.11.2 passed this metric

Testing File Metric

0.11.2 passed this metric

Version Tag Metric

0.11.2 passed this metric