2018-09-06 23:14:18 +08:00
|
|
|
---
|
2019-05-03 05:24:21 +08:00
|
|
|
- name: "Gen_helm_tiller_certs | Create helm config directory (on {{ groups['kube-master'][0] }})"
|
2018-09-06 23:14:18 +08:00
|
|
|
run_once: yes
|
2019-05-03 05:24:21 +08:00
|
|
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
2018-09-06 23:14:18 +08:00
|
|
|
file:
|
|
|
|
path: "{{ helm_config_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: kube
|
|
|
|
|
2019-05-03 05:24:21 +08:00
|
|
|
- name: "Gen_helm_tiller_certs | Create helm script directory (on {{ groups['kube-master'][0] }})"
|
2018-09-06 23:14:18 +08:00
|
|
|
run_once: yes
|
2019-05-03 05:24:21 +08:00
|
|
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
2018-09-06 23:14:18 +08:00
|
|
|
file:
|
|
|
|
path: "{{ helm_script_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: kube
|
|
|
|
|
|
|
|
- name: Gen_helm_tiller_certs | Copy certs generation script
|
|
|
|
run_once: yes
|
2019-05-03 05:24:21 +08:00
|
|
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
2018-10-09 19:43:30 +08:00
|
|
|
template:
|
|
|
|
src: "helm-make-ssl.sh.j2"
|
2018-09-06 23:14:18 +08:00
|
|
|
dest: "{{ helm_script_dir }}/helm-make-ssl.sh"
|
|
|
|
mode: 0700
|
|
|
|
|
2019-05-03 05:24:21 +08:00
|
|
|
- name: "Check_helm_certs | check if helm client certs have already been generated on first master (on {{ groups['kube-master'][0] }})"
|
2018-09-06 23:14:18 +08:00
|
|
|
find:
|
|
|
|
paths: "{{ helm_home_dir }}"
|
|
|
|
patterns: "*.pem"
|
|
|
|
get_checksum: true
|
2019-05-03 05:24:21 +08:00
|
|
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
2018-09-06 23:14:18 +08:00
|
|
|
register: helmcert_master
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: Gen_helm_tiller_certs | run cert generation script
|
|
|
|
run_once: yes
|
2019-05-03 05:24:21 +08:00
|
|
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
2018-09-06 23:14:18 +08:00
|
|
|
command: "{{ helm_script_dir }}/helm-make-ssl.sh -e {{ helm_home_dir }} -d {{ helm_tiller_cert_dir }}"
|
|
|
|
|
2019-05-16 15:27:43 +08:00
|
|
|
- name: Check_helm_client_certs | Set helm_client_certs
|
|
|
|
set_fact:
|
2018-09-06 23:14:18 +08:00
|
|
|
helm_client_certs: ['ca.pem', 'cert.pem', 'key.pem']
|
|
|
|
|
|
|
|
- name: "Check_helm_client_certs | check if a cert already exists on master node"
|
|
|
|
find:
|
|
|
|
paths: "{{ helm_home_dir }}"
|
|
|
|
patterns: "*.pem"
|
|
|
|
get_checksum: true
|
|
|
|
register: helmcert_node
|
|
|
|
when: inventory_hostname != groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: "Check_helm_client_certs | Set 'sync_helm_certs' to true on masters"
|
|
|
|
set_fact:
|
2019-04-11 18:06:10 +08:00
|
|
|
sync_helm_certs: (not item in helmcert_node.files | map(attribute='path') | map("basename") | list or helmcert_node.files | selectattr("path", "equalto", "{{ helm_home_dir }}/{{ item }}") | map(attribute="checksum")|first|default('') != helmcert_master.files | selectattr("path", "equalto", "{{ helm_home_dir }}/{{ item }}") | map(attribute="checksum")|first|default(''))
|
|
|
|
when:
|
|
|
|
- inventory_hostname != groups['kube-master'][0]
|
2018-09-06 23:14:18 +08:00
|
|
|
with_items:
|
|
|
|
- "{{ helm_client_certs }}"
|
|
|
|
|
|
|
|
- name: Gen_helm_tiller_certs | Gather helm client certs
|
2019-04-24 13:18:00 +08:00
|
|
|
# noqa 303 - tar is called intentionally here, but maybe this should be done with the slurp module
|
2018-09-06 23:14:18 +08:00
|
|
|
shell: "tar cfz - -C {{ helm_home_dir }} -T /dev/stdin <<< {{ helm_client_certs|join(' ') }} | base64 --wrap=0"
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
no_log: true
|
|
|
|
register: helm_client_cert_data
|
|
|
|
check_mode: no
|
2019-05-03 05:24:21 +08:00
|
|
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
2018-09-06 23:14:18 +08:00
|
|
|
when: sync_helm_certs|default(false) and inventory_hostname != groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: Gen_helm_tiller_certs | Use tempfile for unpacking certs on masters
|
|
|
|
tempfile:
|
|
|
|
state: file
|
|
|
|
path: /tmp
|
|
|
|
prefix: helmcertsXXXXX
|
|
|
|
suffix: tar.gz
|
|
|
|
register: helm_cert_tempfile
|
|
|
|
when: sync_helm_certs|default(false) and inventory_hostname != groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: Gen_helm_tiller_certs | Write helm client certs to tempfile
|
|
|
|
copy:
|
2019-05-03 05:24:21 +08:00
|
|
|
content: "{{ helm_client_cert_data.stdout }}"
|
|
|
|
dest: "{{ helm_cert_tempfile.path }}"
|
2018-09-06 23:14:18 +08:00
|
|
|
owner: root
|
|
|
|
mode: "0600"
|
|
|
|
when: sync_helm_certs|default(false) and inventory_hostname != groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: Gen_helm_tiller_certs | Unpack helm certs on masters
|
|
|
|
shell: "base64 -d < {{ helm_cert_tempfile.path }} | tar xz -C {{ helm_home_dir }}"
|
|
|
|
no_log: true
|
|
|
|
changed_when: false
|
|
|
|
check_mode: no
|
|
|
|
when: sync_helm_certs|default(false) and inventory_hostname != groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: Gen_helm_tiller_certs | Cleanup tempfile on masters
|
|
|
|
file:
|
2019-05-03 05:24:21 +08:00
|
|
|
path: "{{ helm_cert_tempfile.path }}"
|
2018-09-06 23:14:18 +08:00
|
|
|
state: absent
|
|
|
|
when: sync_helm_certs|default(false) and inventory_hostname != groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: Gen_certs | check certificate permissions
|
|
|
|
file:
|
|
|
|
path: "{{ helm_home_dir }}"
|
|
|
|
group: "{{ helm_cert_group }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ helm_cert_owner }}"
|
|
|
|
mode: "u=rwX,g-rwx,o-rwx"
|
|
|
|
recurse: yes
|