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.

41 lines
1.3 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. get_attributes: no
  6. get_checksum: yes
  7. get_mime: no
  8. delegate_to: "{{ groups['kube_control_plane'][0] }}"
  9. register: known_tokens_master
  10. run_once: true
  11. - name: "Check_tokens | Set default value for 'sync_tokens' and 'gen_tokens' to false"
  12. set_fact:
  13. sync_tokens: false
  14. gen_tokens: false
  15. - name: "Check_tokens | Set 'sync_tokens' and 'gen_tokens' to true"
  16. set_fact:
  17. gen_tokens: true
  18. when: not known_tokens_master.stat.exists and kube_token_auth|default(true)
  19. run_once: true
  20. - name: "Check tokens | check if a cert already exists"
  21. stat:
  22. path: "{{ kube_token_dir }}/known_tokens.csv"
  23. get_attributes: no
  24. get_checksum: yes
  25. get_mime: no
  26. register: known_tokens
  27. - name: "Check_tokens | Set 'sync_tokens' to true"
  28. set_fact:
  29. sync_tokens: >-
  30. {%- set tokens = {'sync': False} -%}
  31. {%- for server in groups['kube_control_plane'] | intersect(ansible_play_batch)
  32. if (not hostvars[server].known_tokens.stat.exists) or
  33. (hostvars[server].known_tokens.stat.checksum|default('') != known_tokens_master.stat.checksum|default('')) -%}
  34. {%- set _ = tokens.update({'sync': True}) -%}
  35. {%- endfor -%}
  36. {{ tokens.sync }}
  37. run_once: true