puppetlabs / puppetlabs-vcsrepo

Support for source control repositories
http://forge.puppetlabs.com/puppetlabs/vcsrepo
GNU General Public License v2.0
223 stars 285 forks source link

Duplicate Error whenever installing vcsrepo module in masterless config #564

Closed bphelan-iss closed 2 years ago

bphelan-iss commented 2 years ago

Describe the Bug

I am installing the vcsrepo module via r10k in a masterless machine. Whenever I install the repo, during compilaton but before the puppet code is run, I get this error:

# puppet apply /etc/puppet Error: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Vcsrepo[/tmp/vcstest/p4_client_root] is already declared at (file: /etc/puppet/modules/vcsrepo/examples/p4/create_client.pp, line: 1); cannot redeclare (file: /etc/puppet/modules/vcsrepo/examples/p4/delete_client.pp, line: 1) (file: /etc/puppet/modules/vcsrepo/examples/p4/delete_client.pp, line: 1, column: 1) on node ip-10-251-0-196.ec2.internal

I noticed that the issue is the "examples/p4" folder which declares the

vcsrepo { '/tmp/vcstest/p4_client_root': twice, which is causing the error.

Here's the reference to the code in question:

https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/main/examples/p4/create_client.pp https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/main/examples/p4/delete_client.pp

Expected Behavior

The module should install and run without issue since this is just a module installation from source

Steps to Reproduce

Steps to reproduce the behavior:

  1. Add mod 'puppetlabs-vcsrepo', '5.2.0' to the Puppetfile
  2. Run r10k puppetfile install --puppetfile /etc/puppet/Puppetfile --moduledir /etc/puppet/modules to install the module
  3. Run puppet apply /etc/puppet

Environment

Additional Context

I have commented out all invocations of vcsrepo in my code and have isolated the issue to the module install

kenyon commented 2 years ago

You're using puppet apply wrong. Apparently when given a directory, it tries to apply every manifest it finds (this behavior doesn't seem to be documented). So it's applying these example code snippets. You need to write some puppet code that manages your machine's configuration, and apply that code. You don't want to just apply every puppet file in every module like you're doing.

bphelan-iss commented 2 years ago

Thank you for the information. I confirmed that running puppet apply /etc/puppet/manifests instead of puppet apply /etc/puppet ran the manifests as expected.

I had set up my environment.conf to set manifests=/etc/puppet/manifests but it appears that puppet apply ignores this file.

It seems I have to explicitly apply the manifests directory, which is a simple code change.

Thanks,

Brian