If you compare the behavior of the Exec type to the Host type, Exec is more flexible because it has a command => parameter. This is useful if you would like to create multiple Execs with different namevars, but similar commands.
When working with the Host type, I've found that the namevar becomes the "canonical_hostname", and there is no way to override this. Here's a specific example of when having multiple Host resources with the same namevar would be useful:
@@host { "$fqdn":
|
host_aliases => $hostname,
|
ip => $private_ip_interface,
|
tag => "normal_server_private-${region}",
|
}
|
|
@@host { "${fqdn}":
|
host_aliases => $hostname,
|
ip => $public_ip_interface,
|
tag => "normal_server_public-${region}",
|
}
|
Since both exported resources have the same namevar, I receive a parse error:
Error 400 on SERVER: Duplicate definition: Host[puppet.dev.server.com] is already defined in file /etc/puppet/modules/hosts/manifests/collect.pp at line 33; cannot redefine at /etc/puppet/modules/hosts/manifests/collect.pp:43 on node puppet.dev.server.com
|
However, If the Host type had the ability to pass a canonical hostname (fqdn) argument, I could do:
@@host { "${fqdn}-private":
|
canonical_hostname => $fqdn
|
host_aliases => $hostname,
|
ip => $private_ip_interface,
|
tag => "normal_server_private-${region}",
|
}
|
|
@@host { "${fqdn}-public":
|
canonical_hostname => $fqdn
|
host_aliases => $hostname,
|
ip => $public_ip_interface,
|
tag => "normal_server_public-${region}",
|
}
|
- relates to
-
PUP-1928 Using hostname as a unique key is not sufficient for /etc/hosts management
-
- Resolved
-
- clones