You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB

  1. ---
  2. - name: "Check_tokens | check if the tokens have already been generated on first master"
  3. stat:
  4. path: "{{ kube_token_dir }}/known_tokens.csv"
  5. delegate_to: "{{groups['kube-master'][0]}}"
  6. register: known_tokens_master
  7. run_once: true
  8. - name: "Check_tokens | Set default value for 'sync_tokens' and 'gen_tokens' to false"
  9. set_fact:
  10. sync_tokens: false
  11. gen_tokens: false
  12. - name: "Check_tokens | Set 'sync_tokens' and 'gen_tokens' to true"
  13. set_fact:
  14. gen_tokens: true
  15. when: not known_tokens_master.stat.exists and kube_token_auth|default(true)
  16. run_once: true
  17. - name: "Check tokens | check if a cert already exists"
  18. stat:
  19. path: "{{ kube_token_dir }}/known_tokens.csv"
  20. register: known_tokens
  21. - name: "Check_tokens | Set 'sync_tokens' to true"
  22. set_fact:
  23. sync_tokens: true
  24. when: >-
  25. {%- set tokens = {'sync': False} -%}
  26. {%- for server in groups['kube-master'] | intersect(ansible_play_batch)
  27. if (not hostvars[server].known_tokens.stat.exists) or
  28. (hostvars[server].known_tokens.stat.checksum|default('') != known_tokens_master.stat.checksum|default('')) -%}
  29. {%- set _ = tokens.update({'sync': True}) -%}
  30. {%- endfor -%}
  31. {{ tokens.sync }}
  32. run_once: true