Ask Your Question
0

Could not evaluate: ip is a required attribute for hosts

asked 2015-06-02 10:11:02 -0500

Philip_ gravatar image

Hi there

On one workstation I get all the time the following error message, if I try to apply my hosts module.

Error message:

[root@lw2016 ~]# puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for lw2016.example.com
Info: Applying configuration version '1432908950'
Notice: /Stage[main]/Hosts/Host[lw2016.example.com]/ensure: created
Info: Computing checksum on file /etc/hosts
Info: FileBucket got a duplicate file {md5}260689e948e29eb2d48421c3597f9cc6
Error: /Stage[main]/Hosts/Host[lw2016.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0433.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0433.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0436.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0436.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0411.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0411.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0441.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0441.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0414.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0414.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0438.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0438.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0415.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0415.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0440.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0440.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0416.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0416.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[localhost]/ensure: created
Error: /Stage[main]/Hosts/Host[localhost]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0417.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0417.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0413.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0413.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: /Stage[main]/Hosts/Host[srv0437.example.com]/ensure: created
Error: /Stage[main]/Hosts/Host[srv0437.example.com]: Could not evaluate: ip is a required attribute for hosts
Notice: Finished catalog run in 3.48 seconds

My module code looks like this:

class hosts{
  file { '/etc/hosts':
    owner => 'root',
    group => 'root',
    mode => '664',
    ensure  => file,
  }
  host { 'localhost':
    ip => '127.0.0.1',
    require => File [ '/etc/hosts' ],
    ensure => present,
  }
  if $::lsbdistid != RedHatEnterpriseWorkstation {
    host { $fqdn:
      ip => $ipaddress_bond0 ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-06-02 23:32:36 -0500

updated 2015-06-03 05:08:52 -0500

I played around with your code and, while I could be wrong, I actually think you've found a bug in Puppet.

To confirm, could you try this -

1) Find the file lib/puppet/provider/host/parsed.rb on your system using locate or find.

2) Find the line that's generating the error message and replace with

raise ArgumentError, "#{n} #{hash.inspect} is a required attribute for hosts" unless hash[n] and hash[n] != :absent

UPDATE: for me this is happening because my test system has no fact $ipaddress_bond0. Strangely, if that fact doesn't exist, it causes failures relating to unrelated hosts file entries. Could you confirm for your system the value of $ipaddress_bond0 by giving the output of

facter ipaddress_bond0

UPDATE: I think this is probably related to PUP-1479

edit flag offensive delete link more
0

answered 2015-06-03 02:53:23 -0500

Philip_ gravatar image

Thanks for the "$ipaddress_bond0" hint. That solved my problem!

Changed

  if $::lsbdistid != RedHatEnterpriseWorkstation {
    host { $fqdn:
      ip => $ipaddress_bond0,
      host_aliases => $hostname,
      require => File [ '/etc/hosts' ],
      ensure => present,
    }
  }

to

  if $::lsbdistid != RedHatEnterpriseWorkstation {
    host { $fqdn:
      ip => $::ipaddress,
      host_aliases => $hostname,
      require => File [ '/etc/hosts' ],
      ensure => present,
    }
  }

Interesting to know would be why the if statement didn't work. Well..:

On the RHEL Workstation with the hosts error there is no "lsbdistid" factor attribute:

[root@lw2016 ~]# facter | grep lsbdistid

While on all other RHEL workstations have it:

[root@lw2001 ~]# facter | grep lsbdistid
lsbdistid => RedHatEnterpriseWorkstation

The workstations are all running the same facter version:

[root@lw2001 ~]# facter --version
2.4.4
[root@lw2016 ~]# facter --version
2.4.4

Any ideas where this issue is coming from?

Thanks.

edit flag offensive delete link more

Comments

Use Below Format

if $::lsbdistid !~ /RedHatEnterpriseWorkstation/ { .. }

shirish shukla gravatar imageshirish shukla ( 2015-06-03 03:46:21 -0500 )edit

Works, thanks.

Philip_ gravatar imagePhilip_ ( 2015-06-03 04:21:07 -0500 )edit

As a point of style I wouldn't use a regular expression here. You have forgotten to quote the string. Should be if $::lsbdistid != 'RedHatEnterpriseWorkstation' { ... }

Alex Harvey gravatar imageAlex Harvey ( 2015-06-03 04:59:32 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-02 10:11:02 -0500

Seen: 223 times

Last updated: Jun 03 '15