2016-04-07 23:08:39 +08:00
|
|
|
---
|
2016-05-13 21:08:28 +08:00
|
|
|
- name: "Check_certs | check if the certs have already been generated on first master"
|
2016-04-07 23:08:39 +08:00
|
|
|
stat:
|
2016-12-27 19:02:45 +08:00
|
|
|
path: "{{ kube_cert_dir }}/{{ item }}"
|
2016-04-11 15:33:08 +08:00
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
2016-04-07 23:08:39 +08:00
|
|
|
register: kubecert_master
|
|
|
|
run_once: true
|
2016-12-27 19:02:45 +08:00
|
|
|
with_items: >-
|
|
|
|
['ca.pem',
|
|
|
|
{% for host in groups['k8s-cluster'] %}
|
|
|
|
'node-{{ host }}-key.pem'
|
|
|
|
{% if not loop.last %}{{','}}{% endif %}
|
|
|
|
{% endfor %}]
|
2016-04-07 23:08:39 +08:00
|
|
|
|
2016-12-27 19:02:45 +08:00
|
|
|
- name: "Check_certs | Set default value for 'sync_certs', 'gen_certs', and 'secret_changed' to false"
|
2016-04-07 23:08:39 +08:00
|
|
|
set_fact:
|
|
|
|
sync_certs: false
|
|
|
|
gen_certs: false
|
2016-12-27 19:02:45 +08:00
|
|
|
secret_changed: false
|
2016-04-07 23:08:39 +08:00
|
|
|
|
2016-12-27 19:02:45 +08:00
|
|
|
- name: "Check_certs | Set 'gen_certs' to true"
|
2016-04-07 23:08:39 +08:00
|
|
|
set_fact:
|
|
|
|
gen_certs: true
|
2016-12-27 19:02:45 +08:00
|
|
|
when: "not {{ item.stat.exists }}"
|
2016-04-07 23:08:39 +08:00
|
|
|
run_once: true
|
2016-12-27 19:02:45 +08:00
|
|
|
with_items: "{{ kubecert_master.results }}"
|
2016-04-07 23:08:39 +08:00
|
|
|
|
|
|
|
- name: "Check certs | check if a cert already exists"
|
|
|
|
stat:
|
2016-12-27 19:02:45 +08:00
|
|
|
path: "{{ kube_cert_dir }}/{{ item }}"
|
2016-05-16 06:15:59 +08:00
|
|
|
register: kubecert
|
2016-12-27 19:02:45 +08:00
|
|
|
with_items:
|
|
|
|
- ca.pem
|
|
|
|
- node-{{ inventory_hostname }}-key.pem
|
2016-04-07 23:08:39 +08:00
|
|
|
|
|
|
|
- name: "Check_certs | Set 'sync_certs' to true"
|
|
|
|
set_fact:
|
|
|
|
sync_certs: true
|
|
|
|
when: >-
|
|
|
|
{%- set certs = {'sync': False} -%}
|
2016-12-27 19:02:45 +08:00
|
|
|
{%- for host in groups['k8s-cluster'] %}
|
|
|
|
{% if host == inventory_hostname %}
|
|
|
|
{% if (not kubecert.results[0].stat.exists|default(False)) or
|
2017-02-08 02:06:48 +08:00
|
|
|
(not kubecert.results[1].stat.exists|default(False)) or
|
2016-12-27 19:02:45 +08:00
|
|
|
(kubecert.results[1].stat.checksum|default('') != kubecert_master.results[loop.index].stat.checksum|default('')) -%}
|
|
|
|
{%- set _ = certs.update({'sync': True}) -%}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2016-04-07 23:08:39 +08:00
|
|
|
{%- endfor -%}
|
|
|
|
{{ certs.sync }}
|