Issue #4131 has been updated by Wil Cooley.

File test_parsed.rb added
File parsed.rb added
Subject changed from host quietly moves resources from default file to target ( 
I assume this applies to all parsedfiles) to resources using parsedfile 
providers quietly move resources from default file to target with 'puppet 
resource'
Affected Puppet version changed from 0.24.8 to 3.2.1-rc1

Daniel Pittman wrote:
> Is this still an issue?

I can confirm that I am seeing this same behavior with a type & provider that I 
am working on that uses parsedfiles with 3.1.1 and 3.2.1-rc1.

It seems to happen with ralsh/'puppet resource' but not when puppet-applying a 
manifest. 

> If so, what semantics do people think that a `hosts` file managing resource 
> pointed at a different target has?  Is it exclusively that you have two 
> master sources, or is it that you have multiple files representing one 
> content space?
> 
> I suspect the answer is that the `target` option is a bad deal, and should 
> never have been included, because it makes the model fundamentally incoherent.

I find being able to change the target useful, for ad hoc testing and for 
generating files that might be distributed outside of Puppet (I still have a 
handful of RHEL4 & Solaris 9 boxes running an older configuration management 
tool).

But the issue is lower-level than the hosts resource -- the issue indeed lies 
with the `provider/parsedfile.rb` provider (or `util/fileparsing.rb`) and 
puppet-resource. *Removing* the resource from the default target is 
particularly surprising and dangerous. One could very easily accidentally do 
this while fumbling about trying to find a way to change the target for 
querying resources (which is what I was looking for before this diverted me).

Attached is a minimal type & provider that uses the parsedfile provider. To 
reproduce the problem, create a `/tmp/test_parsed1` file that has a some 
whitespace-separated data (you could just copy /etc/hosts there, for example).

    $ cat /tmp/test_parsed1
    one line1
    two line2
    three line3

    $ puppet resource --libdir ~/w/puppet-test/modules/lib/ test_parsed
    test_parsed { 'one':
      ensure => 'present',
      data   => 'line1',
      target => '/tmp/test_parsed1',
    }
    test_parsed { 'three':
      ensure => 'present',
      data   => 'line3',
      target => '/tmp/test_parsed1',
    }
    test_parsed { 'two':
      ensure => 'present',
      data   => 'line2',
      target => '/tmp/test_parsed1',
    }

    $ puppet resource --libdir ~/w/puppet-test/modules/lib/ test_parsed three 
target=/tmp/test_parsed2
    Notice: /Test_parsed[three]/target: target changed '/tmp/test_parsed1' to 
'/tmp/test_parsed2'
    test_parsed { 'three':
      ensure => 'present',
      target => '/tmp/test_parsed2',
    }

    $ cat /tmp/test_parsed2
    # HEADER: This file was autogenerated at Mon May 20 15:38:46 -0700 2013
    # HEADER: by puppet.  While it can still be managed manually, it
    # HEADER: is definitely not recommended.
    three line3

    $ cat /tmp/test_parsed1
    # HEADER: This file was autogenerated at Mon May 20 15:38:46 -0700 2013
    # HEADER: by puppet.  While it can still be managed manually, it
    # HEADER: is definitely not recommended.
    one line1
    two line2


----------------------------------------
Bug #4131: resources using parsedfile providers quietly move resources from 
default file to target with 'puppet resource'
https://projects.puppetlabs.com/issues/4131#change-91248

* Author: Dan Bode
* Status: Needs More Information
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* Affected Puppet version: 3.2.1-rc1
* 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
[root@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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to