2016-05-07 01:17:59 +08:00
|
|
|
---
|
2016-05-13 21:08:28 +08:00
|
|
|
- name: "Check_tokens | check if the tokens have already been generated on first master"
|
2016-05-07 01:17:59 +08:00
|
|
|
stat:
|
|
|
|
path: "{{ kube_token_dir }}/known_tokens.csv"
|
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
|
|
|
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 21:15:50 +08:00
|
|
|
when: not known_tokens_master.stat.exists and kube_token_auth|default(true)
|
2016-05-07 01:17:59 +08:00
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: "Check tokens | check if a cert already exists"
|
|
|
|
stat:
|
2017-03-15 19:00:42 +08:00
|
|
|
path: "{{ kube_token_dir }}/known_tokens.csv"
|
2016-05-07 01:17:59 +08:00
|
|
|
register: known_tokens
|
|
|
|
|
|
|
|
- name: "Check_tokens | Set 'sync_tokens' to true"
|
|
|
|
set_fact:
|
|
|
|
sync_tokens: true
|
|
|
|
when: >-
|
|
|
|
{%- set tokens = {'sync': False} -%}
|
2017-03-21 17:31:47 +08:00
|
|
|
{%- for server in groups['kube-master'] | intersect(ansible_play_hosts)
|
2016-05-07 01:17:59 +08:00
|
|
|
if (not hostvars[server].known_tokens.stat.exists) or
|
|
|
|
(hostvars[server].known_tokens.stat.checksum != known_tokens_master.stat.checksum|default('')) -%}
|
|
|
|
{%- set _ = tokens.update({'sync': True}) -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
{{ tokens.sync }}
|
|
|
|
run_once: true
|