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.

63 lines
1.7 KiB

  1. ---
  2. - name: Set external kube-apiserver endpoint
  3. set_fact:
  4. external_apiserver_endpoint: >-
  5. {%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.port is defined -%}
  6. https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
  7. {%- else -%}
  8. https://{{ kube_apiserver_address }}:{{ kube_apiserver_port }}
  9. {%- endif -%}
  10. tags:
  11. - facts
  12. - name: Gather certs for admin kubeconfig
  13. slurp:
  14. src: "{{ item }}"
  15. register: admin_certs
  16. with_items:
  17. - "{{ kube_cert_dir }}/ca.pem"
  18. - "{{ kube_cert_dir }}/admin-{{ inventory_hostname }}.pem"
  19. - "{{ kube_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
  20. when: not kubeadm_enabled|d(false)|bool
  21. - name: Write admin kubeconfig
  22. template:
  23. src: admin.conf.j2
  24. dest: "{{ kube_config_dir }}/admin.conf"
  25. owner: root
  26. group: "{{ kube_cert_group }}"
  27. mode: 0640
  28. when: not kubeadm_enabled|d(false)|bool
  29. - name: Create kube config dir
  30. file:
  31. path: "/root/.kube"
  32. mode: "0700"
  33. state: directory
  34. - name: Copy admin kubeconfig to root user home
  35. copy:
  36. src: "{{ kube_config_dir }}/admin.conf"
  37. dest: "/root/.kube/config"
  38. remote_src: yes
  39. mode: "0700"
  40. backup: yes
  41. - name: Copy admin kubeconfig to ansible host
  42. fetch:
  43. src: "{{ kube_config_dir }}/admin.conf"
  44. dest: "{{ artifacts_dir }}/admin.conf"
  45. flat: yes
  46. validate_checksum: no
  47. run_once: yes
  48. when: kubeconfig_localhost|default(false)
  49. - name: Copy kubectl binary to ansible host
  50. fetch:
  51. src: "{{ bin_dir }}/kubectl"
  52. dest: "{{ artifacts_dir }}/kubectl"
  53. flat: yes
  54. validate_checksum: no
  55. become: no
  56. run_once: yes
  57. when: kubectl_localhost|default(false)