Bug #10991
puppet agent --genconfig generates unusable config
| Status: | Duplicate | Start date: | 11/21/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | - | |||
| Target version: | - | |||
| Affected Puppet version: | 2.6.0 | Branch: | ||
| Keywords: | ||||
| Votes: | 0 |
Description
It’s pretty common to get puppet agent running with a set of command line arguments, e.g. —server, and then run —genconfig, and have puppet just use that. The problem is if puppet has performed fact syncing, so the vardir/facts directory exists, then puppet agent will not start, because it thinks vardir/facts should be a file and will refuse to remove the existing directory.
This issue occurs because Puppet::Util::Settings::FileSetting#type relies on either the setting name containing ‘dir’ or that the value ends with a trailing slash. The setting as contained in the defaults.rb (or output by genconfig) does contain a trailing slash.
But Puppet::Util::Settings::FileSettings#munge uses File.expand_path which strips the trailing slash off. This change was made in commit:97c043f4
This is occurs on Mac and I’ve seen it on windows too.
To reproduce:
$ puppet agent --test ... $ ll ~/.puppet/var/ ... drwxr-xr-x 2 josh staff 68B Oct 31 22:11 facts/ $ puppet agent --genconfig > puppet.conf $ puppet agent --config puppet.conf Could not prepare for execution: Got 1 failure(s) while initializing: change from directory to file failed: Could not set 'file on ensure: Is a directory - /Users/josh/.puppet/var/facts
Comment out the following, then it will start:
#factdest = /Users/josh/.puppet/var/facts/
Or remove existing directory, and it will start:
$ rm -rf ~/.puppet $ puppet agent --config puppet.conf
Relying on a trailing slash is extremely fragile
Related issues
History
Updated by Matthaus Litteken 6 months ago
- Status changed from Unreviewed to Accepted
Updated by Josh Cooper 6 months ago
- Status changed from Accepted to Duplicate