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.

61 lines
2.0 KiB

  1. ---
  2. - name: Parse certificate key if not set
  3. set_fact:
  4. kubeadm_certificate_key: "{{ hostvars[groups['kube-master'][0]]['kubeadm_certificate_key'] }}"
  5. when: kubeadm_certificate_key is undefined
  6. - name: Pull control plane certs down
  7. shell: >-
  8. {{ bin_dir }}/kubeadm join phase
  9. control-plane-prepare download-certs
  10. --certificate-key {{ kubeadm_certificate_key }}
  11. --control-plane
  12. --token {{ kubeadm_token }}
  13. --discovery-token-unsafe-skip-ca-verification
  14. {{ kubeadm_discovery_address }}
  15. &&
  16. {{ bin_dir }}/kubeadm join phase
  17. control-plane-prepare certs
  18. --control-plane
  19. --token {{ kubeadm_token }}
  20. --discovery-token-unsafe-skip-ca-verification
  21. {{ kubeadm_discovery_address }}
  22. args:
  23. creates: "{{ kube_cert_dir }}/apiserver-etcd-client.key"
  24. - name: Delete unneeded certificates
  25. file:
  26. path: "{{ item }}"
  27. state: absent
  28. with_items:
  29. - "{{ kube_cert_dir }}/apiserver.crt"
  30. - "{{ kube_cert_dir }}/apiserver.key"
  31. - "{{ kube_cert_dir }}/ca.key"
  32. - "{{ kube_cert_dir }}/etcd/ca.key"
  33. - "{{ kube_cert_dir }}/etcd/healthcheck-client.crt"
  34. - "{{ kube_cert_dir }}/etcd/healthcheck-client.key"
  35. - "{{ kube_cert_dir }}/etcd/peer.crt"
  36. - "{{ kube_cert_dir }}/etcd/peer.key"
  37. - "{{ kube_cert_dir }}/etcd/server.crt"
  38. - "{{ kube_cert_dir }}/etcd/server.key"
  39. - "{{ kube_cert_dir }}/front-proxy-ca.crt"
  40. - "{{ kube_cert_dir }}/front-proxy-ca.key"
  41. - "{{ kube_cert_dir }}/front-proxy-client.crt"
  42. - "{{ kube_cert_dir }}/front-proxy-client.key"
  43. - "{{ kube_cert_dir }}/sa.key"
  44. - "{{ kube_cert_dir }}/sa.pub"
  45. - name: Calculate etcd cert serial
  46. command: "openssl x509 -in {{ kube_cert_dir }}/apiserver-etcd-client.crt -noout -serial"
  47. register: "etcd_client_cert_serial_result"
  48. changed_when: false
  49. when:
  50. - inventory_hostname in groups['k8s-cluster']|union(groups['calico-rr']|default([]))|unique|sort
  51. tags:
  52. - network
  53. - name: Set etcd_client_cert_serial
  54. set_fact:
  55. etcd_client_cert_serial: "{{ etcd_client_cert_serial_result.stdout.split('=')[1] }}"
  56. tags:
  57. - network