Configuration > Resources

host


Description

This resource manages an entry in the file /etc/hosts. Its main parameter is ip_address.

Relationship to other resources

Hosts (or host entries), as identified by the value of the ip_address parameter, must be unique. In other words there can only be one host entry per IP address.

If there is a file or symlink resource whose path parameter is /etc/hosts, all host resources depend on it implicitly. However it is not possible to manage the contents of the /etc/hosts file via a file resource and manage one or more host resources at the same time. The content and source parameters of the file resource must be omitted in this case to avoi conflicting resource definitions.

Parameters

To declare a resource within the [[resources]] array as a host, set the type meta-parameter to host.

In addition to the meta-parameters listed in Resources, this table lists all resource-specific parameters:

Name TOML type Description Mandatory Default
ensure string

Determines the desired state of the resource. One of:

  • present, meaning the resource is created and kept up-to-date
  • absent, meaning the resource is deleted and kept absent
yes present
ip_address string Primary parameter. The IP address for this host entry. Both IPv4 and IPv6 addresses are allowed. yes
hostname string The canonical hostname associated with the IP address. yes
aliases array of strings One or more host aliases associated with the IP address no

Examples

Minimal

	    
[[resources]]
type = "host"
ip_address = "172.16.0.2"
hostname = "my.example.local"
	    
	  

With aliases

	    
[[resources]]
type = "host"
ip_address = "172.16.0.2"
hostname = "my.example.local"
aliases = [ "my.example", "example" ]