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.

126 lines
3.6 KiB

9 years ago
  1. ---
  2. - name: Pre-upgrade control plane
  3. import_tasks: pre-upgrade.yml
  4. tags:
  5. - k8s-pre-upgrade
  6. - name: Create webhook token auth config
  7. template:
  8. src: webhook-token-auth-config.yaml.j2
  9. dest: "{{ kube_config_dir }}/webhook-token-auth-config.yaml"
  10. mode: 0640
  11. when: kube_webhook_token_auth | default(false)
  12. - name: Create webhook authorization config
  13. template:
  14. src: webhook-authorization-config.yaml.j2
  15. dest: "{{ kube_config_dir }}/webhook-authorization-config.yaml"
  16. mode: 0640
  17. when: kube_webhook_authorization | default(false)
  18. - name: Create kube-scheduler config
  19. template:
  20. src: kubescheduler-config.yaml.j2
  21. dest: "{{ kube_config_dir }}/kubescheduler-config.yaml"
  22. mode: 0644
  23. - name: Apply Kubernetes encrypt at rest config
  24. import_tasks: encrypt-at-rest.yml
  25. when:
  26. - kube_encrypt_secret_data
  27. tags:
  28. - kube-apiserver
  29. - name: Install | Copy kubectl binary from download dir
  30. copy:
  31. src: "{{ downloads.kubectl.dest }}"
  32. dest: "{{ bin_dir }}/kubectl"
  33. mode: 0755
  34. remote_src: true
  35. tags:
  36. - kubectl
  37. - upgrade
  38. - name: Install kubectl bash completion
  39. shell: "{{ bin_dir }}/kubectl completion bash >/etc/bash_completion.d/kubectl.sh"
  40. when: ansible_os_family in ["Debian","RedHat"]
  41. tags:
  42. - kubectl
  43. ignore_errors: true # noqa ignore-errors
  44. - name: Set kubectl bash completion file permissions
  45. file:
  46. path: /etc/bash_completion.d/kubectl.sh
  47. owner: root
  48. group: root
  49. mode: 0755
  50. when: ansible_os_family in ["Debian","RedHat"]
  51. tags:
  52. - kubectl
  53. - upgrade
  54. ignore_errors: true # noqa ignore-errors
  55. - name: Set bash alias for kubectl
  56. blockinfile:
  57. path: /etc/bash_completion.d/kubectl.sh
  58. block: |-
  59. alias {{ kubectl_alias }}=kubectl
  60. if [[ $(type -t compopt) = "builtin" ]]; then
  61. complete -o default -F __start_kubectl {{ kubectl_alias }}
  62. else
  63. complete -o default -o nospace -F __start_kubectl {{ kubectl_alias }}
  64. fi
  65. state: present
  66. marker: "# Ansible entries {mark}"
  67. when:
  68. - ansible_os_family in ["Debian","RedHat"]
  69. - kubectl_alias is defined and kubectl_alias != ""
  70. tags:
  71. - kubectl
  72. - upgrade
  73. ignore_errors: true # noqa ignore-errors
  74. - name: Define nodes already joined to existing cluster and first_kube_control_plane
  75. import_tasks: define-first-kube-control.yml
  76. - name: Include kubeadm setup
  77. import_tasks: kubeadm-setup.yml
  78. - name: Include kubeadm etcd extra tasks
  79. include_tasks: kubeadm-etcd.yml
  80. when: etcd_deployment_type == "kubeadm"
  81. - name: Include kubeadm secondary server apiserver fixes
  82. include_tasks: kubeadm-fix-apiserver.yml
  83. - name: Include kubelet client cert rotation fixes
  84. include_tasks: kubelet-fix-client-cert-rotation.yml
  85. when: kubelet_rotate_certificates
  86. - name: Install script to renew K8S control plane certificates
  87. template:
  88. src: k8s-certs-renew.sh.j2
  89. dest: "{{ bin_dir }}/k8s-certs-renew.sh"
  90. mode: 0755
  91. - name: Renew K8S control plane certificates monthly 1/2
  92. template:
  93. src: "{{ item }}.j2"
  94. dest: "/etc/systemd/system/{{ item }}"
  95. mode: 0644
  96. validate: "sh -c '[ -f /usr/bin/systemd/system/factory-reset.target ] || exit 0 && systemd-analyze verify %s:{{item}}'"
  97. # FIXME: check that systemd version >= 250 (factory-reset.target was introduced in that release)
  98. # Remove once we drop support for systemd < 250
  99. with_items:
  100. - k8s-certs-renew.service
  101. - k8s-certs-renew.timer
  102. register: k8s_certs_units
  103. when: auto_renew_certificates
  104. - name: Renew K8S control plane certificates monthly 2/2
  105. systemd:
  106. name: k8s-certs-renew.timer
  107. enabled: yes
  108. state: started
  109. daemon_reload: "{{ k8s_certs_units is changed }}"
  110. when: auto_renew_certificates