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

Windows consul template failing #1601

Open
tsiamer opened this issue Jul 17, 2022 · 4 comments
Open

Windows consul template failing #1601

tsiamer opened this issue Jul 17, 2022 · 4 comments
Labels
Milestone

Comments

@tsiamer
Copy link

tsiamer commented Jul 17, 2022

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
c9036a4.
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:

@eikenb eikenb added the bug label Jul 18, 2022
@eikenb eikenb added this to the v0.30.0 milestone Jul 18, 2022
@eikenb eikenb modified the milestones: v0.30.0, v0.29.2 Aug 1, 2022
@eikenb
Copy link
Contributor

eikenb commented Aug 15, 2022

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!

@tsiamer
Copy link
Author

tsiamer commented Aug 15, 2022

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

@eikenb
Copy link
Contributor

eikenb commented Aug 15, 2022

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.

@eikenb eikenb removed this from the v0.29.2 milestone Aug 15, 2022
@tsiamer
Copy link
Author

tsiamer commented Aug 15, 2022

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

@eikenb eikenb added this to the v0.30.0 milestone Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants