blob: 888c08724028c56172802a9e973c20488fb7d083 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
---
- name: create certs directory for nfd-worker
file:
path: /etc/kubernetes/node-feature-discovery/certs
state: directory
owner: nobody
group: root
mode: 0500
- name: install CA certificate
copy:
content: "{{ node_feature_discovery_ca_certificate.content | b64decode }}"
dest: /etc/kubernetes/node-feature-discovery/certs/ca.crt
- name: create private key for worker certificate
openssl_privatekey:
path: /etc/kubernetes/node-feature-discovery/certs/tls.key
type: RSA
size: 4096
owner: nobody
group: root
mode: 0400
- name: create signing request for worker certificate
openssl_csr:
path: /etc/kubernetes/node-feature-discovery/certs/tls.csr
privatekey_path: /etc/kubernetes/node-feature-discovery/certs/tls.key
CN: "{{ kubernetes_node_name }}"
key_usage:
- digitalSignature
key_usage_critical: yes
extended_key_usage:
- clientAuth
extended_key_usage_critical: yes
basic_constraints:
- 'CA:FALSE'
basic_constraints_critical: yes
- name: slurp CSR for worker certificate
slurp:
src: /etc/kubernetes/node-feature-discovery/certs/tls.csr
register: node_feature_discovery_worker_csr
- name: check if worker certificate already exists
stat:
path: /etc/kubernetes/node-feature-discovery/certs/tls.crt
register: node_feature_discovery_worker_certificate_stat
- name: read worker certificate validity
when: node_feature_discovery_worker_certificate_stat.stat.exists
openssl_certificate_info:
path: /etc/kubernetes/node-feature-discovery/certs/tls.crt
valid_at:
ten_years: '+3650d'
register: node_feature_discovery_worker_certificate_info
- name: slurp existing worker certificate
when: node_feature_discovery_worker_certificate_stat.stat.exists
slurp:
src: /etc/kubernetes/node-feature-discovery/certs/tls.crt
register: node_feature_discovery_worker_certificate_current
- name: generate worker certificate
delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
community.crypto.x509_certificate_pipe:
content: "{{ node_feature_discovery_worker_certificate_current.content | default('') | b64decode }}"
csr_content: "{{ node_feature_discovery_worker_csr.content | b64decode }}"
provider: ownca
ownca_path: /etc/kubernetes/addons/node-feature-discovery/ca/crt.pem
ownca_privatekey_path: /etc/kubernetes/addons/node-feature-discovery/ca/key.pem
ownca_digest: sha256
ownca_not_after: "+18250d" ## 50 years
force: "{{ node_feature_discovery_worker_certificate_stat.stat.exists and (not node_feature_discovery_worker_certificate_info.valid_at.ten_years) }}"
register: node_feature_discovery_worker_cert
- name: store worker certificate
copy:
content: "{{ node_feature_discovery_worker_cert.certificate }}"
dest: /etc/kubernetes/node-feature-discovery/certs/tls.crt
|