Bug #10919
puppet resource host generates a warning that is not clear
| Status: | Accepted | Start date: | 11/17/2011 | |
|---|---|---|---|---|
| Priority: | Low | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | ralsh | |||
| Target version: | 2.7.x | |||
| Affected Puppet version: | 2.7.6 | Branch: | ||
| Keywords: | ||||
| Votes: | 0 |
Description
Consider an /etc/hosts file that looks like this:
[root@puppet ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.121.132 puppet.puppetlabs.vm
Executing ‘puppet resource host’ to inspect this file produces the following output:
[root@puppet ~]# puppet resource host
warning: Host localhost found in both parsed and parsed; skipping the parsed version
host { 'localhost':
ensure => 'present',
host_aliases => ['localhost.localdomain', 'localhost4', 'localhost4.localdomain4'],
ip => '127.0.0.1',
target => '/etc/hosts',
}
host { 'puppet.puppetlabs.vm':
ensure => 'present',
ip => '192.168.121.132',
target => '/etc/hosts',
}
What is the warning trying to tell me?
I’m using a vanilla CentOS 6 machine with PE2 installed.
Related issues
History
Updated by Stefan Schulte 6 months ago
The problem here is that puppet in general needs a key to identify a resource (the resource’s title) und that key has to be unique. In case of the host type the key is the hostname. So when the provider (in case of the host type we just have one provider: parsed) looks through your host file, it will parse your local host entries like this
host { 'localhost':
ip => '127.0.0.1',
host_aliases => [ 'localhost.localdomain', 'localhost4', 'localhost4.localdomain4' ],
}
host { 'localhost':
ip => '::1',
host_aliases => [ 'localhost.localdomain', 'localhost6', 'localhost6.localdomain6' ],
}
So the provider comes up with two resources called localhost and puppet will just pick one and drop the other (that is what the message is trying to tell you).
I hope the cause of the message is now clear, however you are right that this message is not very helpful. The ultimate solution is of course to somehow support the usecase where you want to manage multiple entries in your host file with the same name.
Updated by Josh Cooper 5 months ago
- Status changed from Unreviewed to Accepted
- Priority changed from Normal to Low
- Target version set to 2.7.x
Updated by Ryan Coleman 5 months ago
Thank you for the explanation, ‘why’ is clear now. Cheers!
Stefan Schulte wrote:
The problem here is that puppet in general needs a key to identify a resource (the resource’s title) und that key has to be unique. In case of the host type the key is the hostname. So when the provider (in case of the host type we just have one provider:
parsed) looks through your host file, it will parse your local host entries like this[…]
So the provider comes up with two resources called localhost and puppet will just pick one and drop the other (that is what the message is trying to tell you).
I hope the cause of the message is now clear, however you are right that this message is not very helpful. The ultimate solution is of course to somehow support the usecase where you want to manage multiple entries in your host file with the same name.