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.

193 lines
4.8 KiB

9 years ago
6 years ago
6 years ago
  1. ---
  2. - import_tasks: facts.yml
  3. tags:
  4. - facts
  5. - import_tasks: pre_upgrade.yml
  6. tags:
  7. - kubelet
  8. - name: Ensure /var/lib/cni exists
  9. file:
  10. path: /var/lib/cni
  11. state: directory
  12. mode: 0755
  13. - import_tasks: install.yml
  14. tags:
  15. - kubelet
  16. - import_tasks: loadbalancer/kube-vip.yml
  17. when:
  18. - is_kube_master
  19. - kube_vip_enabled
  20. tags:
  21. - kube-vip
  22. - import_tasks: loadbalancer/nginx-proxy.yml
  23. when:
  24. - not is_kube_master or kube_apiserver_bind_address != '0.0.0.0'
  25. - loadbalancer_apiserver_localhost
  26. - loadbalancer_apiserver_type == 'nginx'
  27. tags:
  28. - nginx
  29. - import_tasks: loadbalancer/haproxy.yml
  30. when:
  31. - not is_kube_master or kube_apiserver_bind_address != '0.0.0.0'
  32. - loadbalancer_apiserver_localhost
  33. - loadbalancer_apiserver_type == 'haproxy'
  34. tags:
  35. - haproxy
  36. - name: Ensure nodePort range is reserved
  37. sysctl:
  38. name: net.ipv4.ip_local_reserved_ports
  39. value: "{{ kube_apiserver_node_port_range }}"
  40. sysctl_set: yes
  41. sysctl_file: "{{ sysctl_file_path }}"
  42. state: present
  43. reload: yes
  44. when: kube_apiserver_node_port_range is defined
  45. tags:
  46. - kube-proxy
  47. - name: Verify if br_netfilter module exists
  48. command: "modinfo br_netfilter"
  49. environment:
  50. PATH: "{{ ansible_env.PATH }}:/sbin" # Make sure we can workaround RH's conservative path management
  51. register: modinfo_br_netfilter
  52. failed_when: modinfo_br_netfilter.rc not in [0, 1]
  53. changed_when: false
  54. check_mode: no
  55. - name: Verify br_netfilter module path exists
  56. file:
  57. path: /etc/modules-load.d
  58. state: directory
  59. mode: 0755
  60. - name: Enable br_netfilter module
  61. modprobe:
  62. name: br_netfilter
  63. state: present
  64. when: modinfo_br_netfilter.rc == 0
  65. - name: Persist br_netfilter module
  66. copy:
  67. dest: /etc/modules-load.d/kubespray-br_netfilter.conf
  68. content: br_netfilter
  69. mode: 0644
  70. when: modinfo_br_netfilter.rc == 0
  71. # kube-proxy needs net.bridge.bridge-nf-call-iptables enabled when found if br_netfilter is not a module
  72. - name: Check if bridge-nf-call-iptables key exists
  73. command: "sysctl net.bridge.bridge-nf-call-iptables"
  74. failed_when: false
  75. changed_when: false
  76. check_mode: no
  77. register: sysctl_bridge_nf_call_iptables
  78. - name: Enable bridge-nf-call tables
  79. sysctl:
  80. name: "{{ item }}"
  81. state: present
  82. sysctl_file: "{{ sysctl_file_path }}"
  83. value: "1"
  84. reload: yes
  85. when: sysctl_bridge_nf_call_iptables.rc == 0
  86. with_items:
  87. - net.bridge.bridge-nf-call-iptables
  88. - net.bridge.bridge-nf-call-arptables
  89. - net.bridge.bridge-nf-call-ip6tables
  90. - name: Modprobe Kernel Module for IPVS
  91. modprobe:
  92. name: "{{ item }}"
  93. state: present
  94. with_items:
  95. - ip_vs
  96. - ip_vs_rr
  97. - ip_vs_wrr
  98. - ip_vs_sh
  99. when: kube_proxy_mode == 'ipvs'
  100. tags:
  101. - kube-proxy
  102. - name: Modprobe nf_conntrack_ipv4
  103. modprobe:
  104. name: nf_conntrack_ipv4
  105. state: present
  106. register: modprobe_nf_conntrack_ipv4
  107. ignore_errors: true # noqa ignore-errors
  108. when:
  109. - kube_proxy_mode == 'ipvs'
  110. tags:
  111. - kube-proxy
  112. - name: Persist ip_vs modules
  113. copy:
  114. dest: /etc/modules-load.d/kube_proxy-ipvs.conf
  115. mode: 0644
  116. content: |
  117. ip_vs
  118. ip_vs_rr
  119. ip_vs_wrr
  120. ip_vs_sh
  121. {% if modprobe_nf_conntrack_ipv4 is success -%}
  122. nf_conntrack_ipv4
  123. {%- endif -%}
  124. when: kube_proxy_mode == 'ipvs'
  125. tags:
  126. - kube-proxy
  127. - include_tasks: "cloud-credentials/{{ cloud_provider }}-credential-check.yml"
  128. when:
  129. - cloud_provider is defined
  130. - cloud_provider in [ 'openstack', 'azure', 'vsphere' ]
  131. tags:
  132. - cloud-provider
  133. - facts
  134. - name: Test if openstack_cacert is a base64 string
  135. set_fact:
  136. openstack_cacert_is_base64: "{% if openstack_cacert is search ('^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$') %}true{% else %}false{% endif %}"
  137. when:
  138. - cloud_provider is defined
  139. - cloud_provider == 'openstack'
  140. - openstack_cacert is defined
  141. - openstack_cacert | length > 0
  142. - name: Write cacert file
  143. copy:
  144. src: "{{ openstack_cacert if not openstack_cacert_is_base64 else omit }}"
  145. content: "{{ openstack_cacert | b64decode if openstack_cacert_is_base64 else omit }}"
  146. dest: "{{ kube_config_dir }}/openstack-cacert.pem"
  147. group: "{{ kube_cert_group }}"
  148. mode: 0640
  149. when:
  150. - cloud_provider is defined
  151. - cloud_provider == 'openstack'
  152. - openstack_cacert is defined
  153. - openstack_cacert | length > 0
  154. tags:
  155. - cloud-provider
  156. - name: Write cloud-config
  157. template:
  158. src: "cloud-configs/{{ cloud_provider }}-cloud-config.j2"
  159. dest: "{{ kube_config_dir }}/cloud_config"
  160. group: "{{ kube_cert_group }}"
  161. mode: 0640
  162. when:
  163. - cloud_provider is defined
  164. - cloud_provider in [ 'openstack', 'azure', 'vsphere', 'aws', 'gce' ]
  165. notify: Node | restart kubelet
  166. tags:
  167. - cloud-provider
  168. - import_tasks: kubelet.yml
  169. tags:
  170. - kubelet
  171. - kubeadm