Issue #4131 has been updated by Markus Roberts.
Now I can reproduce:
We can't create a host without an IP
<pre>
(markus) ~/projects/puppet (master)> RUBYLIB=lib sudo bin/ralsh host test6
ensure=present target=/tmp/host
notice: /Host[test6]/ensure: created
err: /Host[test6]: Could not evaluate: ip is a required attribute for hosts
host { 'test6':
ensure => 'present',
target => '/tmp/host'
}
</pre>
But we can create one if we provide an IP:
<pre>
(markus) ~/projects/puppet (master)> RUBYLIB=lib sudo bin/ralsh host test6
ensure=present ip='127.0.0.2'
notice: /Host[test6]/ensure: created
host { 'test6':
ensure => 'present',
ip => '127.0.0.2',
target => '/etc/hosts'
}
(markus) ~/projects/puppet (master)> cat /etc/hosts
# HEADER: This file was autogenerated at Fri Jul 02 17:26:23 -0700 2010
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost.localdomain localhost
192.168.1.1 phage.home phage
127.0.0.3 x
1.1.1.1 buildsun4u
0.0.0.0 everywhere
127.0.0.2 test6
</pre>
Note that this added it to /etc/hosts since we didn't change the target. If we
try the first command again:
<pre>
(markus) ~/projects/puppet (master)> RUBYLIB=lib sudo bin/ralsh host test6
ensure=present target=/tmp/host
notice: /Host[test6]/target: target changed '/etc/hosts' to '/tmp/host'
host { 'test6':
ensure => 'present',
target => '/tmp/host'
}
</pre>
It doesn't fail, but instead removes the host from /etc/hosts and puts it in
/tmp/host, as a file only root can read:
<pre>
(markus) ~/projects/puppet (master)> cat /tmp/host
cat: /tmp/host: Permission denied
(markus) ~/projects/puppet (master)> ls -l /tmp/host
-rw------- 1 root wheel 194 Jul 2 17:27 /tmp/host
(markus) ~/projects/puppet (master)> sudo cat /tmp/host
# HEADER: This file was autogenerated at Fri Jul 02 17:27:27 -0700 2010
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.
127.0.0.2 test6
(markus) ~/projects/puppet (master)> cat /etc/hosts
# HEADER: This file was autogenerated at Fri Jul 02 17:27:26 -0700 2010
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost.localdomain localhost
192.168.1.1 phage.home phage
127.0.0.3 x
1.1.1.1 buildsun4u
0.0.0.0 everywhere
</pre>
Of course, the other interesting question is how it added it to /etc/hosts in
the first place:
<pre>
(markus) ~/projects/puppet (master)> ls -l /etc/hosts
-rw-r--r-- 1 root root 436 Jul 2 17:27 /etc/hosts
</pre>
----------------------------------------
Bug #4131: host moves resources from default file to target ( I assume this
applies to all parsedfiles)
http://projects.puppetlabs.com/issues/4131
Author: Dan Bode
Status: Needs more information
Priority: Normal
Assigned to: Dan Bode
Category:
Target version:
Affected version: 2.6alpha1
Keywords:
Branch:
use the host resource and puppet resource:
I expect the following to fail:
<pre>
# puppet resource host test1 ensure=present target="/tmp/host"
host_aliases=alias1
notice: /Host[test1]/ensure: created
err: /Host[test1]: Could not evaluate: ip is a required attribute for hosts
host { 'test1':
host_aliases => ['alias1'],
target => '/tmp/host',
ensure => 'present'
}
</pre>
If there is already an entry for this host in /etc/hosts (the default target),
puppet will use the ip address of that host and move it to the new target
location.
<pre>
# echo '127.0.0.2 test1'> /etc/hosts
[r...@puppet2 puppet_spec]# puppet resource host test1 ensure=present
target="/tmp/host" host_aliases=alias1
notice: /Host[test1]/host_aliases: host_aliases changed '' to 'alias1'
notice: /Host[test1]/target: target changed '/etc/hosts' to '/tmp/host'
host { 'test1':
host_aliases => ['alias1'],
target => '/tmp/host',
ensure => 'present'
}
</pre>
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.