Search code examples
puppet

puppet: Could not back up <file>: Got passed new contents for sum


I had a question I was hoping someone might have an answer to. Essentially what I'm doing is try to ensure I'm always using a fixed, slightly older version of phpunit, which I've placed in my module's file resources.

The manifest:

    file
    {
            "/usr/bin/phpunit":
            ensure => file,
            owner => 'root',
            group => 'root',
            mode => 0755,
            source => "puppet:///modules/php/phpunit"
    }

Preparation: I download the current ('wrong') version of phpunit and place it in /usr/bin.

So the first run puppet succeeds:

Notice: Compiled catalog for <hostname> in environment production in 3.06 seconds
Notice: /Stage[main]/Php/File[/usr/bin/phpunit]/content: content changed '{md5}9f61f732829f4f9e3d31e56613f1a93a' to '{md}38789acbf53196e20e9b89e065cbed94'
Notice: /Stage[main]/Httpd/Service[httpd]: Triggered 'refresh' from 1 events 
Notice: Finished catalog run in 15.86 seconds

Then I download the current (still 'wrong') version of phpunit and place it in /usr/bin again.

This time the puppet run fails.

Notice: Compiled catalog for <hostname> in environment production in 2.96 seconds
Error: Could not back up /usr/bin/phpunit: Got passed new contents for sum {md5}9f61f732829f4f9e3d31e56613f1a93a
Error: Could not back up /usr/bin/phpunit: Got passed new contents for sum {md5}9f61f732829f4f9e3d31e56613f1a93a
Error: /Stage[main]/Php/File[/usr/bin/phpunit]/content: change from {md5}9f61f732829f4f9e3d31e56613f1a93a to {md5}38789acbf53196e20e9b89e065cbed94 failed: Could not back up /usr/bin/phpunit: Got passed new contents for sum {md5}9f61f732829f4f9e3d31e56613f1a93a

What gives? If I delete the file ( /var/lib/puppet/clientbucket/9/f/6/1/f/7/3/2/9f61f732829f4f9e3d31e56613f1a93a/ ) from my filebucket it will work again... for the next run, but not the one after that.

What am I doing wrong?

I'd appreciate any input and thanks in advance.


Solution

  • This has no solution other than to upgrade since there's a bug in certain versions of puppet where files containing both UTF8 and binary characters are treated wrongly, and it results in an error message.

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

    The ridiculously overcomplicated solution I used as a workaround is to have a .tar file in the file resource which notifies an exec which untars and places the actual executable in the correct directory, making sure the timestamp for the latter is newer than the former.

    It's far from ideal but it works in cases like mine where upgrading puppet to the most current version isn't an attractive option.