example42 / puppet-puppet

Puppet module to manage Puppet
http://www.example42.com
Other
10 stars 43 forks source link

source_dir reporting errors on files/directories that exist in /etc/puppet #42

Open StFS opened 11 years ago

StFS commented 11 years ago

Hi.

I was trying to specify the source_dir parameter to put a set of configuration files into /etc/puppet/. I have files and directories there already that I don't want to change so I specified source_dir_purge => false as well. You can see my site.pp file below.

So, in /etc/puppet/environments/production/modules/data/files/puppet/conf/ I have the following files: auth.conf fileserver.conf puppet.conf tagmail.conf

In /etc/puppet I have roughly the following structure:

/etc/puppet/
      +- environments/
      |        +- production/  # contains manifests/ and modules/ dirs from git
      |        +- test/        # contains manifests/ and modules/ dirs from git
      +- ssl/                  # contains puppet certificates
      +- foo.txt               # just some file I want to keep there
      +-.git/                  # my puppet conf is in a git repo
      +- puppet.conf
      +- auth.conf
      +- fileserver.conf
      +- tagmail.conf

What I want is for the puppet module to install the files that are present in my /etc/puppet/environments/production/modules/data/files/puppet/conf/ directory into the /etc/puppet/ directory but leave all the other files and directories in there in peace.

What happens when I run puppet is I get a bunch of warnings and errors relating to the files that are in /etc/puppet (but not in /etc/puppet/environments/production/modules/data/files/puppet/conf/).

An example of this is the following:

Info: Applying configuration version '1366838929'
Notice: /File[puppet.dir]: Not removing directory; use 'force' to override
Notice: /File[puppet.dir]: Not removing directory; use 'force' to override
Error: Could not rename temporary file /etc/puppet.puppettmp_413 to /etc/puppet: Is a directory - /etc/puppet.puppettmp_413 or /etc/puppet
Error: /File[puppet.dir]/ensure: change from directory to file failed: Could not rename temporary file /etc/puppet.puppettmp_413 to /etc/puppet: Is a directory - /etc/puppet.puppettmp_413 or /etc/puppet
Notice: /File[/etc/puppet/ssl]: Dependency File[puppet.dir] has failures: true
Warning: /File[/etc/puppet/ssl]: Skipping because of failed dependencies
Notice: /File[/etc/puppet/.git]: Dependency File[puppet.dir] has failures: true
Warning: /File[/etc/puppet/.git]: Skipping because of failed dependencies

I seem to get one Notice and one Warning line for each file that exists in /etc/puppet/ (and/or subdirectories) and doesn't exist in /etc/puppet/environments/production/modules/data/files/puppet/conf/. I do not get these lines for files that do exist there.

My site.pp:

class base_nopuppet {
  include openssh
  class { 'sudo':
    source => [ "puppet:///modules/data/sudo/sudo.conf-${hostname}" , "puppet:///modules/data/sudo/sudo.conf" ],
  }
  class { 'mailx':
    source => [ "puppet:///modules/data/mailx/mailx.conf-${hostname}" , "puppet:///modules/data/mailx/mailx.conf" ],
  }
}

class base {
  include base_nopuppet
  class { 'puppet':
    source_dir => 'puppet:///modules/data/puppet/conf/',
    source_dir_purge => false,
    template => absent,
  }
}

node default {
  include base
}

node 'puppet.cs.ru.is' {
  include base_nopuppet

  class { 'puppet':
    mode => 'server',
    source_dir => 'puppet:///modules/data/puppet/conf/',
    source_dir_purge => false,                                               
    template => absent,                                                          
  }
}
alvagante commented 11 years ago

I've tried to reproduce the error without success. What version of Puppet are you using? On what distro? One point to notice is that the puppet module already creates auth.conf and namespaceauth.conf and even if you have them in your source dir, the versions used are the ones provided by the module by default. You can however change their content with the parameters template_auth and template_namespaceauth

StFS commented 11 years ago

CentOS 6.4 and Puppet 3.1.1.

The problem was not with the files you mentioned. The problem is with any file or directory that exists in /etc/puppet but not in the source_dir I specify in the Puppet config.

Take for example these two lines: Notice: /File[/etc/puppet/.git]: Dependency File[puppet.dir] has failures: true Warning: /File[/etc/puppet/.git]: Skipping because of failed dependencies

These seem to be appearing because there exists an /etc/puppet/.git directory. I don't have a .git directory in my source_dir.

The behavior I would expect is that any file or directory that exists in source_dir should be copied over to /etc/puppet but any file or directory that exists in /etc/puppet/ but is not present in source_dir should be left alone. But as I say, I'm getting errors on all of those files.

However, this isn't really a problem for me anymore since I'm now specifying only the puppet.conf file and not the whole source dir. I just thought this was strange behavior so I reported the issue.

alvagante commented 11 years ago

Actually what you expect is also the module's expected behaviour, so this is definitively an issue. I leave the ticket open as reminder.