2016-11-09 10:44:41 +00:00
|
|
|
---
|
2016-12-13 09:03:35 +00:00
|
|
|
- name: "Check_certs | check if all certs have already been generated on first master"
|
2016-11-09 10:44:41 +00:00
|
|
|
stat:
|
2016-12-13 09:03:35 +00:00
|
|
|
path: "{{ etcd_cert_dir }}/{{ item }}"
|
2016-11-09 10:44:41 +00:00
|
|
|
delegate_to: "{{groups['etcd'][0]}}"
|
|
|
|
register: etcdcert_master
|
|
|
|
run_once: true
|
2016-12-13 09:03:35 +00:00
|
|
|
with_items: >-
|
|
|
|
['ca.pem',
|
2016-12-23 16:25:37 +00:00
|
|
|
{% set all_etcd_hosts = groups['k8s-cluster']|union(groups['etcd'])|union(groups['calico-rr']|default([]))|unique %}
|
2016-12-13 09:03:35 +00:00
|
|
|
{% for host in all_etcd_hosts %}
|
|
|
|
'node-{{ host }}-key.pem'
|
|
|
|
{% if not loop.last %}{{','}}{% endif %}
|
|
|
|
{% endfor %}]
|
2016-11-09 10:44:41 +00:00
|
|
|
|
2016-12-13 09:03:35 +00:00
|
|
|
- name: "Check_certs | Set default value for 'sync_certs', 'gen_certs' and 'etcd_secret_changed' to false"
|
2016-11-09 10:44:41 +00:00
|
|
|
set_fact:
|
|
|
|
sync_certs: false
|
|
|
|
gen_certs: false
|
2016-12-13 09:03:35 +00:00
|
|
|
etcd_secret_changed: false
|
2016-11-09 10:44:41 +00:00
|
|
|
|
2016-12-13 09:03:35 +00:00
|
|
|
- name: "Check_certs | Set 'gen_certs' to true"
|
2016-11-09 10:44:41 +00:00
|
|
|
set_fact:
|
|
|
|
gen_certs: true
|
2016-12-13 09:03:35 +00:00
|
|
|
when: "not {{item.stat.exists}}"
|
2016-11-09 10:44:41 +00:00
|
|
|
run_once: true
|
2016-12-13 09:03:35 +00:00
|
|
|
with_items: "{{etcdcert_master.results}}"
|
2016-11-09 10:44:41 +00:00
|
|
|
|
|
|
|
- name: "Check certs | check if a cert already exists"
|
|
|
|
stat:
|
2016-12-27 15:26:22 +00:00
|
|
|
path: "{{ etcd_cert_dir }}/{{ item }}"
|
2016-11-09 10:44:41 +00:00
|
|
|
register: etcdcert
|
2016-12-13 09:03:35 +00:00
|
|
|
with_items:
|
|
|
|
- ca.pem
|
|
|
|
- node-{{ inventory_hostname }}-key.pem
|
2016-11-09 10:44:41 +00:00
|
|
|
|
|
|
|
- name: "Check_certs | Set 'sync_certs' to true"
|
|
|
|
set_fact:
|
|
|
|
sync_certs: true
|
|
|
|
when: >-
|
|
|
|
{%- set certs = {'sync': False} -%}
|
2016-12-23 16:25:37 +00:00
|
|
|
{% set all_etcd_hosts = groups['k8s-cluster']|union(groups['etcd'])|union(groups['calico-rr']|default([]))|unique %}
|
2016-12-13 09:03:35 +00:00
|
|
|
{% for host in all_etcd_hosts %}
|
|
|
|
{% if host == inventory_hostname %}
|
|
|
|
{% if (not etcdcert.results[0].stat.exists|default(False)) or
|
|
|
|
(etcdcert.results[1].stat.checksum|default('') != etcdcert_master.results[loop.index].stat.checksum|default('')) -%}
|
|
|
|
{%- set _ = certs.update({'sync': True}) -%}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2016-11-09 10:44:41 +00:00
|
|
|
{%- endfor -%}
|
|
|
|
{{ certs.sync }}
|