Is there any way i can get my windows client to ru...
# puppet-enterprise
g
Is there any way i can get my windows client to run "puppet parser validate" to test my puppet code without installing the whole agent? Installing the Puppet PDK doesn't seem to help....
h
Yes, but requires more work to set up than the packaged puppet agent. You need the correct ruby runtime, the puppet source, and the required gems - basically a set up for doing dev work on puppet itself.
g
So, it would be easier to install the agent separately? And it would be placed in the PATH?
And ruby separately too I guess?
h
Quite a lot to consider in the setup, you probably want a ruby env manager so you can use different versions of ruby for different versions of puppet. If you have other things using ruby you don't want to mess with the systemwide installed ruby. It is for reasons like this the agent package bundles everything and uses the bundled ruby.
If you are not experienced in ruby env and ruby development I would highly recommend using the packaged agent,
g
Sounds like i should be content with the checks that the puppet plugin does for me in vs code. This would be a lot of effort to just check my code before pushing to remote... I was hoping to just add a few lines in a .git/hooks/pre-push file. I didn't realize how much infrastructure is needed... 🙂
h
Puppet parser validate is a syntax only validation, but does not check any semantics. The vstplugin for puppet uses a language server that runs the core puppet parser.
So, you are basically getting the same validation. Then the vst plugin can run puppet-lint and some other validations.
You can configure actions at github so you get validation of your PRs. Look at configs for puppet module repos how it is done.
g
I'm not sure i follow you.. 1. When you say "I would highly recommend using the packaged agent," you mean the separate agent installer that i can find here: https://downloads.puppetlabs.com/windows/puppet8/index.html ? 2) But this would still be a very rudimentary validation, you mean? 3) What is "The vstplugin"? Is it the one used in the VS Code plugin? And i could use that separately for a pre-push check?
h
1. yes (if you want to run puppet commands like validate locally) 2. Rudimentary, yes - same as what you get with the VS Code plugin for puppet. 3. I meant VS Code, which can also run puppet lint - not sure what else you need to install. I always use GitHub actions and push to my fork, and then PR to the main repo. This way I get validation and test that I pushed what I intended, I can correct mistakes without having them show up in a PR to the main repo. I think people use PDK package in their github actions.
t
with pdk you can run
pdk bundle exec puppet parser validate <file>
g
For a CI/CD rookie like me, can you tell me what advantages would I get by checking this in gitlab (in our case) compared to locally?
h
It is after the push. For example you may have forgotten to add a file - it exists locally and test pass, but what you pushed is not the same and tests fail.
g
Ok, thanks for your input! I'll have to think some more about this. It's not trivial to set up, and the VS Code plugin already catches trivial mistakes. There's also the fact that we have not created our modules with "`pdk new module"` but kept the number of files to a bare minimum. So the pdk is less than happy about that... 🙂