-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Example fails, when you have more than one certresolver configured #134
Comments
really useful. thank you for fixing this. to be clear, the solution above should be replaced within the v2 compose example otherwise the unknown operand error will occur. "entrypoint: sh -c 'set -x; apk add jq; while ! [ -e /data/acme.json ] || ! [ |
TL;DR: If you have certs in acme.json, you don't need the while loop and can get past the issues in this issue by removing it. Using the v2 example, with paths slightly modified, is throwing the
Output:
@tobiashochguertel 's example also fails.
output:
I have three resolvers configured. Let's Encrypt, Let's Encrypt Staging, and an internal custom Step Ca. Currently only the Let's Encrypt has any certs in it. So jq gives me: $ jq ".[] | .Certificates | length" /etc/traefik/acme.json
13
0
0 Here is my slightly sanitized compose service: swarm-traefik-certs-dumper:
image: ldez/traefik-certs-dumper:v2.8.1
container_name: swarm-traefik-certs-dumper
hostname: swarm-traefik-certs-dumper
restart: always
entrypoint: sh -c '
apk add jq
; while ! [ -e /etc/traefik/acme.json ]
|| ! [ `jq ".[] | .Certificates | length" /etc/traefik/acme.json` != 0 ]; do
sleep 1
; done
&& traefik-certs-dumper file --version v2 --watch
--source /etc/traefik/acme.json --dest /etc/traefik/certs'
labels:
traefik.enable: "false"
environment:
- LEGO_CA_CERTIFICATES=/usr/local/share/ca-certificates/stepca_root_ca.crt
- LEGO_CA_SERVER_NAME=stepca.internal
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/traefik:/etc/traefik:rw
- /usr/local/share/ca-certificates/stepca_intermediate_ca.crt:/usr/local/share/ca-certificates/stepca_intermediate_ca.crt
- /usr/local/share/ca-certificates/stepca_root_ca.crt:/usr/local/share/ca-certificates/stepca_root_ca.crt
deploy:
restart_policy:
condition: any All that said, if I remove the while loop, it works. entrypoint: sh -c '
apk add jq
&& traefik-certs-dumper file --version v2 --watch
--source /etc/traefik/acme.json --dest /etc/traefik/certs' Now I have my certs in /etc/traefik/certs. While writing this, I started wondering, why isn't the while loop logic in the main binary? Anyway, thanks for the tool :D, hopefully my post will help someone down the road. |
In my case the command jq ".[] | .Certificates | length" /data/acme.json prints out more than one line as I have defined more than one resolver:
|
@ma-ef: Thanks for pointing that out. That helped me a lot. |
I figured out that the following line makes trouble when you have more than one certresolvers activated in your traefik setup:
here a quick way to understand:
I modified the test to the following
jq
command:My complete solution:
Otherwise,
jq ".[] | .Certificates | length"
returns"22 1"
, and then... ! [
jq ".[] | .Certificates | length" /data/acme.json!= 0 ] ...
is evaluated to:... ! [ 22 1 != 0 ] ...
an you get an Errorsh: 1: unknown operand
(reference the issue #128) or as I was playing around to find this issue:./bla.sh: line 3: [: too many arguments
hope this helps, someone who has same issues.
Thanks for this project 👍
The text was updated successfully, but these errors were encountered: