Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekristen/consul-template-plugin-savetofile
Consul Template Plugin to Write Data to Separate Files
https://github.com/ekristen/consul-template-plugin-savetofile
consul-template consul-template-plugin golang
Last synced: about 2 months ago
JSON representation
Consul Template Plugin to Write Data to Separate Files
- Host: GitHub
- URL: https://github.com/ekristen/consul-template-plugin-savetofile
- Owner: ekristen
- License: mit
- Created: 2017-02-03T18:25:26.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-03-29T10:21:15.000Z (almost 4 years ago)
- Last Synced: 2024-06-19T00:35:08.189Z (7 months ago)
- Topics: consul-template, consul-template-plugin, golang
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 16
- Watchers: 3
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# savetofile - a consul-template plugin
Give credit where credit is due, this is based off of https://gist.github.com/tam7t/1b45125ae4de13b3fc6fd0455954c08e I just wanted it in a repo, with releases so I can install the binary through automated means.
I also wanted to tweak it a bit to be just about saving the contents to a file and allow passing of the UID and GID instead of the username along with a few other minor tweaks.
## Usage
```bash
savetofile
```Valid Values for Mode:
* create
* create-nl (will add a `\n` after the contents)
* append
* append-nl (will add a `\n` after the contents)## Example Consul Template Usage
```
{{ with secret "pki/issue/consul" "common_name=consul.example.com" "ttl=1h" }}
{{ if .Data.ca_chain }}
{{ range $key, $value := .Data.ca_chain }}
{{ if eq $key 0 }}
{{ $value | plugin "/usr/local/bin/savetofile" "create-nl" "/etc/consul/ssl/ca.crt" "100" "1000" "644" }}
{{ else }}
{{ $value | plugin "/usr/local/bin/savetofile" "append-nl" "/etc/consul/ssl/ca.crt" "100" "1000" "644" }}
{{ end }}
{{ end }}
{{ end }}
{{ if .Data.certificate }}
{{ .Data.certificate | plugin "/usr/local/bin/savetofile" "create-nl" "/etc/consul/ssl/consul.crt" "100" "1000" "644" }}
{{ end }}{{ if .Data.private_key }}
{{ .Data.private_key | plugin "/usr/local/bin/savetofile" "create-nl" "/etc/consul/ssl/consul.key" "100" "1000" "600" }}
{{ end }}
{{ end }}```
## License
MIT