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


hostsfile (22) Versions 1.0.2

Provides an resource for managing the /etc/hosts file

cookbook 'hostsfile', '= 1.0.2'
cookbook 'hostsfile', '= 1.0.2', :supermarket
knife cookbook site install hostsfile
knife cookbook site download hostsfile
Quality -%

hostsfile LWRP

Build Status

hostsfile provides an LWRP for managing your hosts file using Chef.


  • Chef 10 or higher
  • Ruby 1.8.7 or higher


<table> <tr> <th>Attribute</th> <th>Description</th> <th>Example</th> <th>Default</th> </tr> <tr> <td>ip_address</td> <td>(name attribute) the IP address for the entry</td> <td><tt></tt></td> <td></td> </tr> <tr> <td>hostname</td> <td>(required) the hostname associated with the entry</td> <td><tt></tt></td> <td></td> </tr> <tr> <td>aliases</td> <td>array of aliases for the entry</td> <td><tt>['']</tt></td> <td><tt>[]</tt></td> </tr> <tr> <td>comment</td> <td>a comment to append to the end of the entry</td> <td><tt>'interal DNS server'</tt></td> <td><tt>nil</tt></td> </tr> <tr> <td>priority</td> <td>the relative position of this entry</td> <td><tt>20</tt></td> <td>(varies, see Priorities section)</td> </tr> </table>


Please note: As of v0.1.2, specifying a hostname or alias that exists in another entry will remove that hostname from the other entry before adding to this one. For example:


hostsfile_entry '' do
  hostname  ''

would yield an /etc/hosts file like this:


Creates a new hosts file entry. If an entry already exists, it will be overwritten by this one.

hostsfile_entry '' do
  hostname  ''
  action    :create

This will create an entry like this:


Create a new hosts file entry, only if one does not already exist for the given IP address. If one exists, this does nothing.

hostsfile_entry '' do
  hostname  ''
  action    :create_if_missing


Append a hostname or alias to an existing record. If the given IP address doesn't not already exist in the hostsfile, this method behaves the same as create. Otherwise, it will append the additional hostname and aliases to the existing entry. # Created by Chef
hostsfile_entry '' do
  hostname  ''
  aliases   ['', '']
  comment   'Append by Recipe X'
  action    :append

would yield: # Created by Chef, Appended by Recipe X


Updates the given hosts file entry. Does nothing if the entry does not exist.

hostsfile_entry '' do
  hostname  ''
  comment   'Update by Chef'
  action    :update

This will create an entry like this:           example # Updated by Chef


Removes an entry from the hosts file. Does nothing if the entry does not exist.

hostsfile_entry '' do
  action    :remove

This will remove the entry for


If you're using Berkshelf, just add hostsfile to your Berksfile:

cookbook 'hostsfile'

Otherwise, install the cookbook from the community site:

knife cookbook site install hostsfile

Have any other cookbooks depend on hostsfile by editing editing the metadata.rb for your cookbook.

# metadata.rb
depends 'hostsfile'


Priority is a relatively new addition to the cookbook. It gives you the ability to (somewhat) specify the relative order of entries. By default, the priority is calculated for you as follows:

  1. Local, loopback
  2. IPV4
  3. IPV6

However, you can override it using the priority option.


  1. Fork the project
  2. Create a feature branch corresponding to you change
  3. Commit and test thoroughly
  4. Create a Pull Request on github
    • ensure you add a detailed description of your changes

License and Authors

Copyright 2012 Seth Vargo, CustomInk, LLC

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, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

arcgis-enterprise Applicable Versions
archlinux Applicable Versions
baseserver Applicable Versions
chef_dnsmasq Applicable Versions
cloudbees-cjp-ha Applicable Versions
common_linux Applicable Versions
corosync Applicable Versions
dirsrv Applicable Versions
foreman Applicable Versions
fqdn Applicable Versions
ganeti Applicable Versions
gemirro Applicable Versions
gotcms Applicable Versions
hostname Applicable Versions
hostname-chef13 Applicable Versions
hostnames Applicable Versions
kagent Applicable Versions
letsencrypt-boulder-server Applicable Versions
lxmx_hostname Applicable Versions
opennms Applicable Versions
pacemaker Applicable Versions
paramount Applicable Versions
postgresql-cluster Applicable Versions
riak-cluster Applicable Versions
singularity Applicable Versions
stackstorm Applicable Versions
supermarket-omnibus-cookbook Applicable Versions
system Applicable Versions

No quality metric results found