2016-05-06 17:17:59 +00:00
|
|
|
---
|
2016-05-13 13:08:28 +00:00
|
|
|
- name: "Check_tokens | check if the tokens have already been generated on first master"
|
2016-05-06 17:17:59 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ kube_token_dir }}/known_tokens.csv"
|
2021-02-10 13:36:59 +00:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: yes
|
|
|
|
get_mime: no
|
2021-03-24 00:26:05 +00:00
|
|
|
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
2016-05-06 17:17:59 +00:00
|
|
|
register: known_tokens_master
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: "Check_tokens | Set default value for 'sync_tokens' and 'gen_tokens' to false"
|
|
|
|
set_fact:
|
|
|
|
sync_tokens: false
|
|
|
|
gen_tokens: false
|
|
|
|
|
|
|
|
- name: "Check_tokens | Set 'sync_tokens' and 'gen_tokens' to true"
|
|
|
|
set_fact:
|
|
|
|
gen_tokens: true
|
2017-02-27 13:15:50 +00:00
|
|
|
when: not known_tokens_master.stat.exists and kube_token_auth|default(true)
|
2016-05-06 17:17:59 +00:00
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: "Check tokens | check if a cert already exists"
|
|
|
|
stat:
|
2017-03-15 11:00:42 +00:00
|
|
|
path: "{{ kube_token_dir }}/known_tokens.csv"
|
2021-02-10 13:36:59 +00:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: yes
|
|
|
|
get_mime: no
|
2016-05-06 17:17:59 +00:00
|
|
|
register: known_tokens
|
|
|
|
|
|
|
|
- name: "Check_tokens | Set 'sync_tokens' to true"
|
|
|
|
set_fact:
|
2018-10-16 06:47:04 +00:00
|
|
|
sync_tokens: >-
|
2016-05-06 17:17:59 +00:00
|
|
|
{%- set tokens = {'sync': False} -%}
|
2021-03-24 00:26:05 +00:00
|
|
|
{%- for server in groups['kube_control_plane'] | intersect(ansible_play_batch)
|
2020-06-29 19:39:59 +00:00
|
|
|
if (not hostvars[server].known_tokens.stat.exists) or
|
|
|
|
(hostvars[server].known_tokens.stat.checksum|default('') != known_tokens_master.stat.checksum|default('')) -%}
|
|
|
|
{%- set _ = tokens.update({'sync': True}) -%}
|
2016-05-06 17:17:59 +00:00
|
|
|
{%- endfor -%}
|
|
|
|
{{ tokens.sync }}
|
|
|
|
run_once: true
|