You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatically inject tls-san when api_endpoint differs from hostname (#434)
* Auto-add --tls-san={{ api_endpoint }} when it differs from ansible_hostname
* Ensures first server generates certificate with all required SANs
* Add .ansible/ and PR_DESCRIPTION.md to gitignore
Signed-off-by: Guillaume Andre <[email protected]>
Copy file name to clipboardExpand all lines: roles/k3s_agent/tasks/main.yml
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,28 @@
41
41
}) }}
42
42
changed_when: true
43
43
44
+
- name: Compute final agent arguments
45
+
ansible.builtin.set_fact:
46
+
_api_endpoint_in_agent_config: >-
47
+
{% if agent_config_yaml is defined and api_endpoint is defined and agent_config_yaml | regex_search('tls-san:.*' + api_endpoint | regex_escape(), ignorecase=True) %}
48
+
true
49
+
{% else %}
50
+
false
51
+
{% endif %}
52
+
_api_endpoint_in_agent_args: >-
53
+
{% if api_endpoint is defined and extra_agent_args | regex_search('--tls-san[=\s]+' + api_endpoint | regex_escape(), ignorecase=True) %}
54
+
true
55
+
{% else %}
56
+
false
57
+
{% endif %}
58
+
59
+
- name: Add TLS SAN to agent arguments if needed
60
+
ansible.builtin.set_fact:
61
+
opt_tls_san: >-
62
+
{% if api_endpoint is defined and api_endpoint != ansible_hostname and _api_endpoint_in_agent_config | bool == false and _api_endpoint_in_agent_args | bool == false %}
Copy file name to clipboardExpand all lines: roles/k3s_server/tasks/main.yml
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,29 @@
46
46
regexp: '\.\s+<\(k3s completion bash\)'
47
47
line: ". <(k3s completion bash) # Added by k3s-ansible"
48
48
49
+
- name: Compute final server arguments
50
+
ansible.builtin.set_fact:
51
+
_api_endpoint_in_config: >-
52
+
{% if server_config_yaml is defined and api_endpoint is defined and server_config_yaml | regex_search('tls-san:.*' + api_endpoint | regex_escape(), ignorecase=True) %}
53
+
true
54
+
{% else %}
55
+
false
56
+
{% endif %}
57
+
_api_endpoint_in_args: >-
58
+
{% if api_endpoint is defined and extra_server_args | regex_search('--tls-san[=\s]+' + api_endpoint | regex_escape(), ignorecase=True) %}
59
+
true
60
+
{% else %}
61
+
false
62
+
{% endif %}
63
+
64
+
- name: Add TLS SAN to server arguments if needed
65
+
ansible.builtin.set_fact:
66
+
final_server_args: >-
67
+
{{ extra_server_args }}
68
+
{% if api_endpoint is defined and api_endpoint != ansible_hostname and _api_endpoint_in_config | bool == false and _api_endpoint_in_args | bool == false %}
0 commit comments