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.

42 lines
1.8 KiB

7 years ago
  1. {% set counter = {'dns': 6,'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. [alt_names]
  10. DNS.1 = kubernetes
  11. DNS.2 = kubernetes.default
  12. DNS.3 = kubernetes.default.svc
  13. DNS.4 = kubernetes.default.svc.{{ dns_domain }}
  14. DNS.5 = localhost
  15. {% for host in groups['kube-master'] %}
  16. DNS.{{ counter["dns"] }} = {{ host }}{{ increment(counter, 'dns') }}
  17. {% endfor %}
  18. {% if apiserver_loadbalancer_domain_name is defined %}
  19. DNS.{{ counter["dns"] }} = {{ apiserver_loadbalancer_domain_name }}{{ increment(counter, 'dns') }}
  20. {% endif %}
  21. {% for host in groups['kube-master'] %}
  22. {% if hostvars[host]['access_ip'] is defined %}
  23. IP.{{ counter["ip"] }} = {{ hostvars[host]['access_ip'] }}{{ increment(counter, 'ip') }}
  24. {% endif %}
  25. IP.{{ counter["ip"] }} = {{ hostvars[host]['ip'] | default(hostvars[host]['ansible_default_ipv4']['address']) }}{{ increment(counter, 'ip') }}
  26. {% endfor %}
  27. {% if kube_apiserver_ip is defined %}
  28. IP.{{ counter["ip"] }} = {{ kube_apiserver_ip }}{{ increment(counter, 'ip') }}
  29. {% endif %}
  30. {% if loadbalancer_apiserver is defined and loadbalancer_apiserver.address is defined %}
  31. IP.{{ counter["ip"] }} = {{ loadbalancer_apiserver.address }}{{ increment(counter, 'ip') }}
  32. {% endif %}
  33. {% if supplementary_addresses_in_ssl_keys is defined %}
  34. {% for addr in supplementary_addresses_in_ssl_keys %}
  35. {% if addr | ipaddr %}
  36. IP.{{ counter["ip"] }} = {{ addr }}{{ increment(counter, 'ip') }}
  37. {% else %}
  38. DNS.{{ counter["dns"] }} = {{ addr }}{{ increment(counter, 'dns') }}
  39. {% endif %}
  40. {% endfor %}
  41. {% endif %}
  42. IP.{{ counter["ip"] }} = 127.0.0.1