Skip to content

Commit 80bfcaa

Browse files
keukoAlex-Welsh
authored andcommitted
[letsencrypt] Avoid rendering empty --key-type argument
The `--key-type` argument was always rendered in the command, even if the `letsencrypt_key_type` variable was empty. This caused the command to fail due to an invalid empty argument. The template now checks if `letsencrypt_key_type` has a non-zero length before including `--key-type`, ensuring correct rendering of the script. Change-Id: I66a76fc8d27bcc97cd3133eed137fd46ea599511 (cherry picked from commit 11d889d) Signed-off-by: Bartosz Bezak <[email protected]>
1 parent 545f55f commit 80bfcaa

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

ansible/roles/letsencrypt/templates/letsencrypt-lego-run.sh.j2

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,44 @@
44

55
{% if 'external' in letsencrypt_managed_certs and kolla_external_fqdn != kolla_external_vip_address %}
66
# External Certificates
7-
/usr/bin/letsencrypt-certificates --external --fqdns {% for fqdn in letsencrypt_external_fqdns %}{{ fqdn }}{% if not loop.last %},{% endif %}{% endfor %} --days {{ letsencrypt_cert_valid_days }} --port {{ letsencrypt_webserver_port }} --mail {{ letsencrypt_email }} --acme {{ letsencrypt_external_cert_server }} --vips {% if not kolla_same_external_internal_vip %}{{ kolla_external_vip_address }},{% endif %}{{ kolla_internal_vip_address }} --haproxies-ssh {% for host in groups['loadbalancer'] %}{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ haproxy_ssh_port }}{% if not loop.last %},{% endif %}{% endfor %}{% if letsencrypt_external_account_binding | bool %} --eab --hmac {{ letsencrypt_eab_hmac }} --kid {{ letsencrypt_eab_key_id }}{% endif %} --key-type {{ letsencrypt_key_type }} 2>&1 | tee -a /var/log/kolla/letsencrypt/letsencrypt-lego.log
7+
/usr/bin/letsencrypt-certificates \
8+
--external \
9+
--fqdns {% for fqdn in letsencrypt_external_fqdns %}{{ fqdn }}{% if not loop.last %},{% endif %}{% endfor %} \
10+
--days {{ letsencrypt_cert_valid_days }} \
11+
--port {{ letsencrypt_webserver_port }} \
12+
--mail {{ letsencrypt_email }} \
13+
--acme {{ letsencrypt_external_cert_server }} \
14+
--vips {% if not kolla_same_external_internal_vip %}{{ kolla_external_vip_address }},{% endif %}{{ kolla_internal_vip_address }} \
15+
--haproxies-ssh {% for host in groups['loadbalancer'] %}{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ haproxy_ssh_port }}{% if not loop.last %},{% endif %}{% endfor %} \
16+
{% if letsencrypt_external_account_binding | bool %}
17+
--eab \
18+
--hmac {{ letsencrypt_eab_hmac }} \
19+
--kid {{ letsencrypt_eab_key_id }} \
20+
{% endif %}
21+
{% if letsencrypt_key_type | length > 0 %}
22+
--key-type {{ letsencrypt_key_type }} \
23+
{% endif %} 2>&1 | tee -a /var/log/kolla/letsencrypt/letsencrypt-lego.log
824
{% endif %}
25+
926
{% if 'internal' in letsencrypt_managed_certs and kolla_internal_fqdn != kolla_internal_vip_address %}
1027
# Internal Certificates
11-
/usr/bin/letsencrypt-certificates --internal --fqdns {% for fqdn in letsencrypt_internal_fqdns %}{{ fqdn }}{% if not loop.last %},{% endif %}{% endfor %} --days {{ letsencrypt_cert_valid_days }} --port {{ letsencrypt_webserver_port }} --mail {{ letsencrypt_email }} --acme {{ letsencrypt_internal_cert_server }} --vips {% if not kolla_same_external_internal_vip %}{{ kolla_external_vip_address }},{% endif %}{{ kolla_internal_vip_address }} --haproxies-ssh {% for host in groups['loadbalancer'] %}{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ haproxy_ssh_port }}{% if not loop.last %},{% endif %}{% endfor %}{% if letsencrypt_external_account_binding | bool %} --eab --hmac {{ letsencrypt_eab_hmac }} --kid {{ letsencrypt_eab_key_id }}{% endif %}{% if letsencrypt_key_type | length > 0 %} --key-type {{ letsencrypt_key_type }}{% endif %} 2>&1 | tee -a /var/log/kolla/letsencrypt/letsencrypt-lego.log
28+
/usr/bin/letsencrypt-certificates \
29+
--internal \
30+
--fqdns {% for fqdn in letsencrypt_internal_fqdns %}{{ fqdn }}{% if not loop.last %},{% endif %}{% endfor %} \
31+
--days {{ letsencrypt_cert_valid_days }} \
32+
--port {{ letsencrypt_webserver_port }} \
33+
--mail {{ letsencrypt_email }} \
34+
--acme {{ letsencrypt_internal_cert_server }} \
35+
--vips {% if not kolla_same_external_internal_vip %}{{ kolla_external_vip_address }},{% endif %}{{ kolla_internal_vip_address }} \
36+
--haproxies-ssh {% for host in groups['loadbalancer'] %}{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ haproxy_ssh_port }}{% if not loop.last %},{% endif %}{% endfor %} \
37+
{% if letsencrypt_external_account_binding | bool %}
38+
--eab \
39+
--hmac {{ letsencrypt_eab_hmac }} \
40+
--kid {{ letsencrypt_eab_key_id }} \
41+
{% endif %}
42+
{% if letsencrypt_key_type | length > 0 %}
43+
--key-type {{ letsencrypt_key_type }} \
44+
{% endif %} 2>&1 | tee -a /var/log/kolla/letsencrypt/letsencrypt-lego.log
1245
{% endif %}
1346

1447
{{ cron_cmd }}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed certificate script rendering in Let's Encrypt role.
5+
`LP#2115230 <https://bugs.launchpad.net/kolla-ansible/+bug/2115230>`__

0 commit comments

Comments
 (0)