Windows consul template failing
Please note that the Consul Template issue tracker is reserved for bug reports and enhancements. For general usage questions, please use the Consul Community Portal or the Consul mailing list:
https://discuss.hashicorp.com/c/consul
https://groups.google.com/forum/#!forum/consul-tool
Please try to simplify the issue as much as possible and include all the details to replicate it. The shorter and simpler the bug is to reproduce the quicker it can be addressed. Thanks.
Consul Template version
consul-template_0.29.1
Run consul-template -v to show the version. If you are not
running the latest version, please upgrade before submitting an
issue.
Configuration
# Copy-paste your configuration files here. Only include what is necessary or
# what you've changed from defaults. Include all referenced configurations.
# Copy-paste your Consul Template template here
# Include sample data you reference in the template from Consul or Vault here.
Command
# Place your Consul Template command here
Debug output
Provide a link to a GitHub Gist containing the complete debug
output by running with -log-level=trace.
Expected behavior
What should have happened?
Actual behavior
What actually happened?
Consul template windows failing , i checked here:
Allow setting ownership by name by lukas-w · Pull Request #1541 · hashicorp/consul-template · GitHub, but seems we cant omit the permission part, getting the error below chown nginx.key: not supported by windows when writing the key.
2022-07-14T19:05:49.524+0100 [ERR] (cli) nginxcert.tpl: execute: template: :5:11: executing “” at <writeToFile “nginx.key” “test” “Administrators” “”>: error calling writeToFile: # chown nginx.key: not supported by windows
writeToFile “nginx.key” “test” “Administrators” "" if i leave the permission blank it errors out with missing args. When i test with a user not member of nay groups, it gives the same above error, missing args https://github.com/hashicorp/consul-template/pull/1531/commits/c9036a408c3473387dbf28306d62a11826c4c97d. Apologies i did created a request in consul discuss to no avail.
Thanks
Steps to reproduce
References
Are there any other GitHub issues (open or closed) that should be linked here? For example:
- GH-1234
- ...
Hey @tsiamer, thanks for reporting this.
I'm working this a bit blind as I don't have a windows machine to test on, but looking through the code it seems like this form should work on Windows...
"content" | writeToFile "/my/file/path.txt" "" "" "0644"
It should skip Chown if the user/group are blanks and Chmod has limited support but ignores what it doesn't use, so that should work.
It's hard to tell exactly what you tried but it looked like all your cases had the user/group set which is unsupported by Windows but (as I said above) is skipped if set to blanks.
Please let me know if this doesn't fix it and, if it doesn't, please provide the template snippets you tried.
Thanks and good luck!
Hey @tsiamer, thanks for reporting this.
I'm working this a bit blind as I don't have a windows machine to test on, but looking through the code it seems like this form should work on Windows...
"content" | writeToFile "/my/file/path.txt" "" "" "0644"It should skip Chown if the user/group are blanks and Chmod has limited support but ignores what it doesn't use, so that should work.
It's hard to tell exactly what you tried but it looked like all your cases had the user/group set which is unsupported by Windows but (as I said above) is skipped if set to blanks.
Please let me know if this doesn't fix it and, if it doesn't, please provide the template snippets you tried.
Thanks and good luck!
Hi Eikenb, thanks again for your help,
if i leave the permission blank, it errors out with missing args.
{{- with pkiCert "pki_int/issue/nginx" "ttl=10m" "common_name=test.exampple.com" -}}
{{ .Cert }}
{{ .CA }}
{{ if .Key }}
{{ .Key | writeToFile "/etc/nginx/certs/nginx.key" "" "" "0600" }}
{{ end }}{{ end }}
if you i put local admin:
{{- with pkiCert "pki_int/issue/nginx" "ttl=10m" "common_name=test.exampple.com" -}}
{{ .Cert }}
{{ .CA }}
{{ if .Key }}
{{ .Key | writeToFile "/etc/nginx/certs/nginx.key" "admin" "admin" "0644" }}
{{ end }}{{ end }}
It complains about "0644" chown not supported by windows.
Thanks
Thanks for the quick reply.
Weird... that first version seems like it should work and the second should give a "syscall.EWINDOWS [..] error, wrapped in *PathError." Sounds like it is almost getting the arguments in the wrong order, but they are fixed position arguments so that doesn't seem possible.
I think this might need to wait until I get a chance to reproduce it on Windows... I currently don't have a setup for that.
Thanks for the quick reply.
Weird... that first version seems like it should work and the second should give a "syscall.EWINDOWS [..] error, wrapped in *PathError." Sounds like it is almost getting the arguments in the wrong order, but they are fixed position arguments so that doesn't seem possible.
I think this might need to wait until I get a chance to reproduce it on Windows... I currently don't have a setup for that.
Thank you i tried many options but it just wont work, hopefully you will get it working.
Thanks