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.

78 lines
2.2 KiB

  1. ---
  2. - include: check-certs.yml
  3. tags: [k8s-secrets, facts]
  4. - include: check-tokens.yml
  5. tags: [k8s-secrets, facts]
  6. - name: Make sure the certificate directory exits
  7. file:
  8. path: "{{ kube_cert_dir }}"
  9. state: directory
  10. mode: o-rwx
  11. group: "{{ kube_cert_group }}"
  12. - name: Make sure the tokens directory exits
  13. file:
  14. path: "{{ kube_token_dir }}"
  15. state: directory
  16. mode: o-rwx
  17. group: "{{ kube_cert_group }}"
  18. - name: Make sure the users directory exits
  19. file:
  20. path: "{{ kube_users_dir }}"
  21. state: directory
  22. mode: o-rwx
  23. group: "{{ kube_cert_group }}"
  24. - name: Populate users for basic auth in API
  25. lineinfile:
  26. dest: "{{ kube_users_dir }}/known_users.csv"
  27. create: yes
  28. line: '{{ item.value.pass }},{{ item.key }},{{ item.value.role }}'
  29. backup: yes
  30. with_dict: "{{ kube_users }}"
  31. when: inventory_hostname in "{{ groups['kube-master'] }}" and kube_basic_auth|default(true)
  32. notify: set secret_changed
  33. #
  34. # The following directory creates make sure that the directories
  35. # exist on the first master for cases where the first master isn't
  36. # being run.
  37. #
  38. - name: "Gen_certs | Create kubernetes config directory (on {{groups['kube-master'][0]}})"
  39. file:
  40. path: "{{ kube_config_dir }}"
  41. state: directory
  42. owner: kube
  43. run_once: yes
  44. delegate_to: "{{groups['kube-master'][0]}}"
  45. tags: [kubelet, k8s-secrets, kube-controller-manager, kube-apiserver, bootstrap-os, apps, network, master, node]
  46. when: gen_certs|default(false) or gen_tokens|default(false)
  47. - name: "Gen_certs | Create kubernetes script directory (on {{groups['kube-master'][0]}})"
  48. file:
  49. path: "{{ kube_script_dir }}"
  50. state: directory
  51. owner: kube
  52. run_once: yes
  53. delegate_to: "{{groups['kube-master'][0]}}"
  54. tags: [k8s-secrets, bootstrap-os]
  55. when: gen_certs|default(false) or gen_tokens|default(false)
  56. - name: "Get_tokens | Make sure the tokens directory exits (on {{groups['kube-master'][0]}})"
  57. file:
  58. path: "{{ kube_token_dir }}"
  59. state: directory
  60. mode: o-rwx
  61. group: "{{ kube_cert_group }}"
  62. run_once: yes
  63. delegate_to: "{{groups['kube-master'][0]}}"
  64. when: gen_tokens|default(false)
  65. - include: "gen_certs_{{ cert_management }}.yml"
  66. tags: k8s-secrets
  67. - include: gen_tokens.yml
  68. tags: k8s-secrets