You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
2.2 KiB

  1. {% set counter = {'dns': 2,'ip': 1,} %}{% macro increment(dct, key, inc=1)%}{% if dct.update({key: dct[key] + inc}) %} {% endif %}{% endmacro %}[req]
  2. req_extensions = v3_req
  3. distinguished_name = req_distinguished_name
  4. [req_distinguished_name]
  5. [ v3_req ]
  6. basicConstraints = CA:FALSE
  7. keyUsage = nonRepudiation, digitalSignature, keyEncipherment
  8. subjectAltName = @alt_names
  9. [ ssl_client ]
  10. extendedKeyUsage = clientAuth, serverAuth
  11. basicConstraints = CA:FALSE
  12. subjectKeyIdentifier=hash
  13. authorityKeyIdentifier=keyid,issuer
  14. subjectAltName = @alt_names
  15. [ v3_ca ]
  16. basicConstraints = CA:TRUE
  17. keyUsage = nonRepudiation, digitalSignature, keyEncipherment
  18. subjectAltName = @alt_names
  19. authorityKeyIdentifier=keyid:always,issuer
  20. [alt_names]
  21. DNS.1 = localhost
  22. {% for host in groups['etcd'] %}
  23. {% if hostvars[host]['etcd_access_address'] is defined and not (hostvars[host]['etcd_access_address'] | ansible.utils.ipaddr) %}
  24. {# If defined, the address which etcd uses to access its members must be included in the SAN, otherwise etcd will fail with a TLS error upon startup. #}
  25. DNS.{{ counter["dns"] }} = {{ hostvars[host]['etcd_access_address'] }}{{ increment(counter, 'dns') }}
  26. {% endif %}
  27. {# This will always expand to inventory_hostname, which can be a completely arbitrary name, that etcd will not know or care about, hence this line is (probably) redundant. #}
  28. DNS.{{ counter["dns"] }} = {{ host }}{{ increment(counter, 'dns') }}
  29. {% endfor %}
  30. {% if apiserver_loadbalancer_domain_name is defined %}
  31. DNS.{{ counter["dns"] }} = {{ apiserver_loadbalancer_domain_name }}{{ increment(counter, 'dns') }}
  32. {% endif %}
  33. {% for etcd_alt_name in etcd_cert_alt_names %}
  34. DNS.{{ counter["dns"] }} = {{ etcd_alt_name }}{{ increment(counter, 'dns') }}
  35. {% endfor %}
  36. {% for host in groups['etcd'] %}
  37. {% if hostvars[host]['access_ip'] is defined %}
  38. IP.{{ counter["ip"] }} = {{ hostvars[host]['access_ip'] }}{{ increment(counter, 'ip') }}
  39. {% endif %}
  40. IP.{{ counter["ip"] }} = {{ hostvars[host]['ip'] | default(fallback_ips[host]) }}{{ increment(counter, 'ip') }}
  41. {% endfor %}
  42. {% for cert_alt_ip in etcd_cert_alt_ips %}
  43. IP.{{ counter["ip"] }} = {{ cert_alt_ip }}{{ increment(counter, 'ip') }}
  44. {% endfor %}
  45. IP.{{ counter["ip"] }} = 127.0.0.1