Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow validation of control repos #289

Closed
bittner opened this issue Sep 9, 2017 · 8 comments
Closed

Allow validation of control repos #289

bittner opened this issue Sep 9, 2017 · 8 comments

Comments

@bittner
Copy link

bittner commented Sep 9, 2017

The tools included with pdk (puppet-lint, rubocop, etc. as listed in the table on top of the README) are obviously meant to be run via pdk.

Their executables are all located in /opt/puppetlabs/pdk/share/cache/ruby/2.1.0/bin/, not in /opt/puppetlabs/bin/, which does not make them accessible by default from the command line.

There are two shortcomings to this:

  1. Some people may like to simply run puppet-lint and other commands directly. The only sane way (from a sysadmin point of view) to fix this is by installing (the Debian package) puppet-lint. This may, however, install a different version of the linter, potentially leading to different validation results.
  2. puppet-lint normally also validates a control repository, not only a module. We simply run puppet-lint . in the repository root, usually. Now, pdk validate does not like this idea as you can see below.
$ pdk validate
pdk (FATAL): This command must be run from inside a module (no metadata.json found)

A solution to 1.) would be to make puppet-lint directly accessible by placing it in /opt/puppetlabs/bin/ (or so).

As for 2.) I'm not sure how you guys want us to validate control repositories using the pdk command. I would like to for sure.

@DavidS
Copy link
Contributor

DavidS commented Sep 11, 2017

Control-repo workflows are currently not implemented. A trivial extension would be for i in modules/*; do pushd $i; pdk validate; popd; done. Admittedly that is not very convenient.

@bittner
Copy link
Author

bittner commented Sep 11, 2017

Do you plan to allow a simple way of just calling puppet-lint, w/o metadata magic?

@alvagante
Copy link

FYI, on https://github.com/example42/psick we manage to run current pdk on the whole control repo, we have add to adda local metadata.json, (and there's also a control-repo level rspec tests layout)

@TJM
Copy link

TJM commented Sep 26, 2017

I agree that it needs to be possible to run puppet-lint and puppet parser validate outside of a "module" directory. I would even be willing to try pdk bundle exec puppet-lint, but even the "escape hatch" validates the metadata.json.

@DavidS
Copy link
Contributor

DavidS commented Sep 27, 2017

That's not a deliberate restriction. I've created https://tickets.puppetlabs.com/browse/PDK-544 for removing the metadata.json requirement for pdk bundle. Please subscribe there for updates.

@TJM
Copy link

TJM commented Sep 28, 2017

OK, so upon further effort, and based on the note from @alvagante above, I created a bogus control_repo module with pdk new module control_repo then copied the resulting files into the control-repo. I was then able to run pdk validate (pdk validate puppet) ... which also set it up so that I can use pdk bundle exec puppet-lint if I so desire. I think the bare minimum is the metadata.json (which can probably be {}) and a Gemfile, which I just copied from the new bogus module. The Gemfile I copied was quite long, but it seemed to work and only drew on modules that were "staged" in PDK, so I didn't need Internet access (corporate firewall/proxy causing problems for us on that one). Hope this helps someone! :)

@bittner
Copy link
Author

bittner commented Oct 24, 2017

@TJM Thanks for the hint! Most of the magic for getting this running seems to be in the Gemfile. .rubocop.yml and .gitignore is also helpful.

In any case, there should better be a pdk new command that prepares all this, including the Puppetfile, the hieradata, site/profile, site/role folders and the manifests/site.pp file. Probably in a separate issue.

@bittner
Copy link
Author

bittner commented Oct 24, 2017

Closing this issue in favor of #333.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants