Configuration

Variables


Variables are defined within the [variables] table in client configuration files. Almost every resource parameter from resources defined in a [[resources]] array can be substituted with a variable. Since clients inherit the resources from groups that they are a member of, variable substitution at the client level applies to resources from groups as well, once they are loaded into the client resource catalog.

Each type of resource has parameters that are described in a table in the resource documentation, e.g. in host. Each of these parameters (except for meta-parameters) can be substituted by a variable. The "TOML type" (see table) can be seen as the final type of the value in the parameter, after variable substitution has taken place. As such the type of the variable in [variables] must match the expected TOML type of the parameter that is being substituted.

To replace the value of a parameter with a variable, specify a string in the format "$pullconf::<variable-name>". variable-name must match a key in the [variables] table.

Note that if a variable is used to substitute the value of a parameter whose type is complex, e.g an array or a table, the values within the complex type can be variables as well. Variables can thus be nested.

In summary there are two ways to specify values for parameters in a resource description:

The following variables are reserved and can always be used in configuration files, regardless of other variables defined in the [variables] array.

Name Value Example
hostname The hostname of the client. The hostname is determined by the name of the client configuration file. See client. my.example.com

Limitations

It is currently not possible to template values using variables. Variables can only be used to substitute the whole value of a given parameter. For example given a variable some-variable with the string value xyz, the string abc$pullconf::some-variable would not even be detected as a variable by pullconfd, much less substituted to abcxyz. It is only possible to specify the string $pullconf::some-variable and have it substituted by xyz.

This will change in the future to allow composing strings (and other types) from a templated string containing multiple variables.

Examples

Substitution of primitive TOML types

	    
# ../clients/my.example.com.toml
api-key = "..."

[variables]
internal-ip-address = "172.16.3.46"

[[resources]]
type = "host"
ensure = "present"
ip-address = "$pullconf::internal-ip-address"
hostname = "$pullconf::hostname"
	    
	  

	    
# ../clients/my.example.com.toml
api-key = "..."

[variables]
system = true

[[resources]]
type = "group"
ensure = "present"
name = "example-group"
system = "$pullconf::system"
	    
	  

Substitution of complex TOML types

	    
# ../clients/my.example.com.toml
api-key = "..."

[variables]
aliases = [ "my.example", "example", "$pullconf::another-alias" ]
another-alias = "last.alias"

[[resources]]
type = "host"
ensure = "present"
ip-address = "172.16.3.46"
hostname = "$pullconf::hostname"
aliases = "$pullconf::aliases"