Matthew Mosesohn
7 years ago
6 changed files with 101 additions and 39 deletions
Unified View
Diff Options
-
6roles/kubernetes/master/templates/manifests/kube-apiserver.manifest.j2
-
2roles/kubernetes/master/templates/manifests/kube-controller-manager.manifest.j2
-
4roles/kubernetes/node/templates/node-kubeconfig.yaml.j2
-
47roles/kubernetes/secrets/files/make-ssl.sh
-
33roles/kubernetes/secrets/tasks/check-certs.yml
-
48roles/kubernetes/secrets/tasks/gen_certs.yml
@ -1,36 +1,49 @@ |
|||||
--- |
--- |
||||
- name: "Check_certs | check if the certs have already been generated on first master" |
- name: "Check_certs | check if the certs have already been generated on first master" |
||||
stat: |
stat: |
||||
path: "{{ kube_cert_dir }}/ca.pem" |
|
||||
|
path: "{{ kube_cert_dir }}/{{ item }}" |
||||
delegate_to: "{{groups['kube-master'][0]}}" |
delegate_to: "{{groups['kube-master'][0]}}" |
||||
register: kubecert_master |
register: kubecert_master |
||||
run_once: true |
run_once: true |
||||
|
with_items: >- |
||||
|
['ca.pem', |
||||
|
{% for host in groups['k8s-cluster'] %} |
||||
|
'node-{{ host }}-key.pem' |
||||
|
{% if not loop.last %}{{','}}{% endif %} |
||||
|
{% endfor %}] |
||||
|
|
||||
- name: "Check_certs | Set default value for 'sync_certs' and 'gen_certs' to false" |
|
||||
|
- name: "Check_certs | Set default value for 'sync_certs', 'gen_certs', and 'secret_changed' to false" |
||||
set_fact: |
set_fact: |
||||
sync_certs: false |
sync_certs: false |
||||
gen_certs: false |
gen_certs: false |
||||
|
secret_changed: false |
||||
|
|
||||
- name: "Check_certs | Set 'sync_certs' and 'gen_certs' to true" |
|
||||
|
- name: "Check_certs | Set 'gen_certs' to true" |
||||
set_fact: |
set_fact: |
||||
gen_certs: true |
gen_certs: true |
||||
when: not kubecert_master.stat.exists |
|
||||
|
when: "not {{ item.stat.exists }}" |
||||
run_once: true |
run_once: true |
||||
|
with_items: "{{ kubecert_master.results }}" |
||||
|
|
||||
- name: "Check certs | check if a cert already exists" |
- name: "Check certs | check if a cert already exists" |
||||
stat: |
stat: |
||||
path: "{{ kube_cert_dir }}/ca.pem" |
|
||||
|
path: "{{ kube_cert_dir }}/{{ item }}" |
||||
register: kubecert |
register: kubecert |
||||
|
with_items: |
||||
|
- ca.pem |
||||
|
- node-{{ inventory_hostname }}-key.pem |
||||
|
|
||||
- name: "Check_certs | Set 'sync_certs' to true" |
- name: "Check_certs | Set 'sync_certs' to true" |
||||
set_fact: |
set_fact: |
||||
sync_certs: true |
sync_certs: true |
||||
when: >- |
when: >- |
||||
{%- set certs = {'sync': False} -%} |
{%- set certs = {'sync': False} -%} |
||||
{%- for server in play_hosts |
|
||||
if (not hostvars[server].kubecert.stat.exists|default(False)) or |
|
||||
(hostvars[server].kubecert.stat.checksum|default('') != kubecert_master.stat.checksum|default('')) -%} |
|
||||
{%- set _ = certs.update({'sync': True}) -%} |
|
||||
|
{%- for host in groups['k8s-cluster'] %} |
||||
|
{% if host == inventory_hostname %} |
||||
|
{% if (not kubecert.results[0].stat.exists|default(False)) or |
||||
|
(kubecert.results[1].stat.checksum|default('') != kubecert_master.results[loop.index].stat.checksum|default('')) -%} |
||||
|
{%- set _ = certs.update({'sync': True}) -%} |
||||
|
{% endif %} |
||||
|
{% endif %} |
||||
{%- endfor -%} |
{%- endfor -%} |
||||
{{ certs.sync }} |
{{ certs.sync }} |
||||
run_once: true |
|
Write
Preview
Loading…
Cancel
Save