Bug #829

Multiple source with recursion error

Added by Paul Andreassen over 4 years ago. Updated almost 4 years ago.

Status:Closed Start date:
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:-
Target version:0.24.0
Affected Puppet version: Branch:
Keywords:
Votes: 0

Description

When using multiple sources with recursion, if the file exists in the second source, the first source is used to retrieve the file. This results in a error.

recurse.patch (620 Bytes) Paul Andreassen, 09/21/2007 09:37 am

History

Updated by Anonymous over 4 years ago

Could you please provide more information, such as a test.pp and the error message?

Updated by Paul Andreassen over 4 years ago

Boy, oh Boy, you have asked for it now. You could just review the change and see it is a simple programing error.

Here is the detailed problem. As simple as I could make it. It is so hard to reproduce.

Two sourced directories.

# l /etc/puppet/files/silver/etc/
total 20K
drwxr-xr-x 3 root root   39 2007-09-27 00:51 X11/
drwxr-xr-x 2 root root   23 2007-09-24 17:21 cron.d/
drwxr-sr-t 2 root lp     23 2007-09-26 14:26 cups/
drwxr-xr-x 2 root root   26 2007-09-02 14:16 dhcp3/
-rw-r--r-- 1 root root 2.3K 2007-09-19 11:30 fstab
-rw-r--r-- 1 root root  467 2007-09-02 20:06 hosts
-rw-r--r-- 1 root root 4.2K 2007-09-19 23:53 lilo.conf
drwxr-xr-x 2 root root   17 2007-09-25 13:13 modprobe.d/
-rw-r--r-- 1 root root  323 2007-09-21 09:32 modules

# l /etc/puppet/files/debian/etc/
total 4.0K
drwxr-xr-x 2 root root  25 2007-09-19 09:28 apt/
-rw-r--r-- 1 root root 868 2007-09-19 11:44 updatedb.conf

The test.pp file.

# cat /etc/puppet/manifests/site.pp
define remotedir($source1, $source2, $server = puppet,
        $backup = false, $recurse = true, $sourceselect = all, $replace = true) {
    file { $name:
        source       => [
                "puppet://$server/files/${source1}${name}",
                "puppet://$server/files/${source2}${name}"
        ],
        backup       => $backup,
        recurse      => $recurse,
        sourceselect => $sourceselect,
        replace      => $replace,

#        noop         => true,
    }
}
node default {
    remotedir { "/etc":
        source1 => "$hostname",
        source2 => "debian",
    }
}

Running puppet.

# puppetd --test
notice: Ignoring cache
info: Caching configuration at /var/lib/puppet/state/localconfig.yaml
notice: Starting configuration run
info: //default/remotedir[/etc]/File[/etc/fstab]/source: No specified sources exist
info: //default/remotedir[/etc]/File[/etc/hosts]/source: No specified sources exist
err: //default/remotedir[/etc]/File[/etc/cups/cupsd.conf]/source: Could not retrieve /files/silver/etc/cups/cupsd.conf: Permission denied - /etc/puppet/files/silver/etc/cups/cupsd.conf
info: //default/remotedir[/etc]/File[/etc/lilo.conf]/source: No specified sources exist
info: //default/remotedir[/etc]/File[/etc/X11/xorg.conf]/source: No specified sources exist
info: //default/remotedir[/etc]/File[/etc/modules]/source: No specified sources exist
info: Sent transaction report in 0.22 seconds
notice: Finished configuration run in 30.03 seconds

The test.pp file with sources reversed.

# cat /etc/puppet/manifests/site.pp
define remotedir($source1, $source2, $server = puppet,
        $backup = false, $recurse = true, $sourceselect = all, $replace = true) {
    file { $name:
        source       => [
                "puppet://$server/files/${source1}${name}",
                "puppet://$server/files/${source2}${name}"
        ],
        backup       => $backup,
        recurse      => $recurse,
        sourceselect => $sourceselect,
        replace      => $replace,

#        noop         => true,
    }
}
node default {
    remotedir { "/etc":
        source1 => "debian",
        source2 => "$hostname",
    }
}

Running puppet again.

# puppetd --test
notice: Ignoring cache
info: Caching configuration at /var/lib/puppet/state/localconfig.yaml
notice: Starting configuration run
info: //default/remotedir[/etc]/File[/etc/updatedb.conf]/source: No specified sources exist
err: //default/remotedir[/etc]/File[/etc/cups/cupsd.conf]/source: Could not retrieve /files/silver/etc/cups/cupsd.conf: Permission denied - /etc/puppet/files/silver/etc/cups/cupsd.conf
info: Sent transaction report in 0.14 seconds
notice: Finished configuration run in 30.92 seconds

See simple.

Updated by Anonymous over 4 years ago

  • Status changed from 1 to 2

Updated by Luke Kanies over 4 years ago

  • Status changed from 2 to Closed
  • 7 set to fixed

I applied your patch in commit:9236179fadf5d0ee68abab395ba1102cd04f3471, but I could neither get a test written to expose the bug nor figure out from looking at the code how it could actually cause a problem, because the ‘source’ variable is not used again in the block, so it getting reassigned couldn’t actually have an impact.

Either way, it’s an innocent-enough patch and it certainly was a coding bug, so I applied it. Hopefully it fixes your problem, anyway.

Updated by James Turnbull almost 4 years ago

  • Target version changed from 4 to 0.24.0

Also available in: Atom PDF