-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add support for supplying --var file #15
Conversation
I looked at supplying environment variables as well, but that was a bit more involved so if necessary, a later PR. |
I should have mentioned - worked with packer 1.2.4.
|
(I'm pretty sure the permission-denied part is because I have two goss provisioners and there's no exists-check for the previously-downloaded binary, or that I've previously installed goss to |
I was looking at PR'ing this myself, so big thanks for you taking it on. My big question when going through writing the code myself was how to associate a vars file with each test. It kind of seems to me that currently this plugin does not allow per-test gossfile specification and then therefore also per-test var file specification. That seems like a problem unless you cram all of your tests together and are not doing i.e. role-based testing. |
I address that by different provisioner blocks (one for assertions that are not subject to e.g. network transients, one for ones that are), and by using a packer variable substitution to choose the name of the vars file to use. For example {
"goss_file": "local_only.goss.yaml",
"tests": [
"ansible/tests/baseline.goss.yaml",
"ansible/tests/bd_platform.goss.yaml",
"ansible/tests/buildkite_agent.goss.yaml",
"ansible/tests/local_only.goss.yaml",
"ansible/tests/node_metrics.goss.yaml"
],
"type": "goss",
"use_sudo": true,
"vars_file": "ansible/tests/{{user `environment`}}.vars.goss.yaml",
"version": "0.3.5"
},
{
"goss_file": "remote_dependencies.goss.yaml",
"tests": [
"ansible/tests/remote_dependencies.goss.yaml"
],
"type": "goss",
"use_sudo": true,
"vars_file": "ansible/tests/{{user `environment`}}.vars.goss.yaml",
"version": "0.3.5"
} |
Oh nice workaround. However, intrinsic support for that in the plugin would be nice as the Packer template would then be cleaner. |
@mschuchard Sure - I wasn't able to think of how goss would be invoked in the way that I think you mean, though, so I haven't made an attempt. |
Something like this for the interface would be great. "tests": [{
"dir": "ansible/tests",
"goss_file": "local_only.goss.yaml",
"vars_file": "ansible/tests/{{user `environment`}}.vars.goss.yaml"
},
{
"dir": "other/tests",
"goss_file": "goss_tests.yaml",
"vars_file": "other/more_vars.yaml"
}] Which would require a refactoring of the plugin. Additionally, using the GOSS API instead of the CLI would be nice, but one step at a time. |
I understand a bit more, but have not yet grokked what it means you can achieve? |
Thanks for this PR @petemounce! We'll have a look asap. |
@fishnix thanks :) |
Thanks for the merge! If you have any ideas for how to support environment variable pass through (I had a look and the packer remote command API is a little limited; I could only come up with a way that would work on non Windows), I might be up for that as well. |
So that one can take advantage of goss' templating feature, add support to upload, then use, a vars file.
goss docs: https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#templates