The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Bug #10704

puppet's idea of /etc/hosts management does not match real world use

Добавил(а) Bill Tong больше 4 лет назад. Обновлено около 2 лет назад.

Статус:AcceptedНачата:11/10/2011
Приоритет:HighДата выполнения:
Назначена:-Готовность:

0%

Категория:host
Версия:3.x
Affected Puppet version:2.7.6 Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket is now tracked at: https://tickets.puppetlabs.com/browse/PUP-1928


Описание

Here is a valid extract from an /etc/hosts files on a RHEL box:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Here is the code to make puppet add these entries:

    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', ],
   }

Notice the “localhost” part is the same in both cases. This causes a problem:

Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Host[localhost] is already defined in file /etc/puppet/modules/networking/manifests/init.pp

puppet-2.7.6-2.el6.noarch


Связанные задачи

связана с Puppet - Feature #9454: The host type should allow multiple IP addresses for a host Accepted 09/13/2011

История

#1 Обновлено Bill Tong больше 4 лет назад

Note: the presence of just the first host{} entry will delete the ipv6 entry from /etc/hosts – not good!

#2 Обновлено Cody Herriges больше 4 лет назад

Because of the model that Puppet follows and its requirement of uniqueness this is a tricky thing to satisfy without the breakdown of Puppet’s declarative operation. In this specific case, either each line would have to be accompanied by a unique comment or each entry needs a composite namevar. My latest attempt at getting composite namevars into Puppet can be found at https://github.com/ody/puppet/tree/feature/master/composite_namevar, based off another PSE’s attempt at the same problem. Composite namevars still needs a lot of work. My code functions in my smoke testing but causes ~800 Puppet unit and spec tests to fail.

#3 Обновлено Cody Herriges больше 4 лет назад

  • Параметр Статус изменился с Unreviewed на Needs Decision

#4 Обновлено Bill Tong больше 4 лет назад

Can’t the key for the hostfile be based on both the ip and the hostname together?

#5 Обновлено Аноним больше 4 лет назад

  • Параметр Назначена изменился на Nigel Kersten

Bil Tong wrote:

Can’t the key for the hostfile be based on both the ip and the hostname together?

Actually, the model of /etc/hosts is inconsistent, where some platforms filter duplicate entries and others don’t, based any of the fields.

The least worst model is that the IP address, of which there is one record per line, is the unique key, and the official name and aliases hang from that; this exposes the platform inconsistency around handling duplicate hostname entries to the user, but isn’t too terrible.

The parser should be tolerant of duplicate IP rows, however, and merge those into a uniqified set of host names and aliases.

That would give the least worst behaviour given the way that different platforms handle this content.

In other words: the bug as reported is correct, and our model is not consistent with the real world needs for management of entries in /etc/hosts.

#6 Обновлено Nigel Kersten больше 4 лет назад

  • Параметр Статус изменился с Needs Decision на Accepted
  • Значение Nigel Kersten параметра Назначена удалено
  • Параметр Приоритет изменился с Normal на High
  • Параметр Версия изменился на 3.x

I’d like to target this at a version earlier than Telly, but I can’t see how we could do this without changing behavior significantly.

Am I being too paranoid?

#7 Обновлено James Turnbull больше 4 лет назад

Daniel’s comments seem to suggest we can work around this is in the host parsedfile provider? Or Daniel do you mean the parser itself?

#8 Обновлено Аноним больше 4 лет назад

James Turnbull wrote:

Daniel’s comments seem to suggest we can work around this is in the host parsedfile provider? Or Daniel do you mean the parser itself?

No, Nigel is right: the current model is broken and needs to be replaced. This is an incompatible change, and is effectively completely replacing the hosts type. It is the correct change, of course, but that doesn’t make it any less costly.

My comment about the parser is related to the need to handle the malformed data that will be found in the real world, as well as to reflect the inconsistent cross-platform behaviour in the face of that malformed data.

(Also, none of the proposed multi-key bits are any more correct; they break things worse, making the whole problem harder to solve in the long term.)

#9 Обновлено Philip Wigg больше 3 лет назад

I would just like to add that Windows seems to have a limit of nine host aliases per line.

So if you want to alias more than nine hosts to an IP, you need multiple lines starting with the same IP address.

#10 Обновлено Martin Hagström около 2 лет назад

Redmine Issue #10704 has been migrated to JIRA:

https://tickets.puppetlabs.com/browse/PUP-1928

Экспортировать в Atom PDF