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.

208 lines
6.4 KiB

  1. ---
  2. - include: pre-upgrade.yml
  3. tags: [upgrade, bootstrap-os]
  4. - name: Force binaries directory for Container Linux by CoreOS
  5. set_fact:
  6. bin_dir: "/opt/bin"
  7. when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  8. tags: facts
  9. - name: check bin dir exists
  10. file:
  11. path: "{{bin_dir}}"
  12. state: directory
  13. owner: root
  14. become: true
  15. tags: bootstrap-os
  16. - include: gitinfos.yml
  17. when: run_gitinfos
  18. tags: facts
  19. - include: set_facts.yml
  20. tags: facts
  21. - name: gather os specific variables
  22. include_vars: "{{ item }}"
  23. with_first_found:
  24. - files:
  25. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
  26. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
  27. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  28. - "{{ ansible_distribution|lower }}.yml"
  29. - "{{ ansible_os_family|lower }}.yml"
  30. - defaults.yml
  31. paths:
  32. - ../vars
  33. skip: true
  34. tags: facts
  35. - name: Create kubernetes config directory
  36. file:
  37. path: "{{ kube_config_dir }}"
  38. state: directory
  39. owner: kube
  40. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  41. tags: [kubelet, k8s-secrets, kube-controller-manager, kube-apiserver, bootstrap-os, apps, network, master, node]
  42. - name: Create kubernetes script directory
  43. file:
  44. path: "{{ kube_script_dir }}"
  45. state: directory
  46. owner: kube
  47. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  48. tags: [k8s-secrets, bootstrap-os]
  49. - name: Create kubernetes manifests directory
  50. file:
  51. path: "{{ kube_manifest_dir }}"
  52. state: directory
  53. owner: kube
  54. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  55. tags: [kubelet, bootstrap-os, master, node]
  56. - name: check cloud_provider value
  57. fail:
  58. msg: "If set the 'cloud_provider' var must be set either to 'generic', 'gce', 'aws', 'azure' or 'openstack'"
  59. when: cloud_provider is defined and cloud_provider not in ['generic', 'gce', 'aws', 'openstack', 'azure']
  60. tags: [cloud-provider, facts]
  61. - include: openstack-credential-check.yml
  62. when: cloud_provider is defined and cloud_provider == 'openstack'
  63. tags: [cloud-provider, openstack, facts]
  64. - include: azure-credential-check.yml
  65. when: cloud_provider is defined and cloud_provider == 'azure'
  66. tags: [cloud-provider, azure, facts]
  67. - name: Create cni directories
  68. file:
  69. path: "{{ item }}"
  70. state: directory
  71. owner: kube
  72. with_items:
  73. - "/etc/cni/net.d"
  74. - "/opt/cni/bin"
  75. when: kube_network_plugin in ["calico", "weave", "canal"] and "{{ inventory_hostname in groups['k8s-cluster'] }}"
  76. tags: [network, calico, weave, canal, bootstrap-os]
  77. - name: Update package management cache (YUM)
  78. yum: update_cache=yes name='*'
  79. when: ansible_pkg_mgr == 'yum'
  80. tags: bootstrap-os
  81. - name: Install latest version of python-apt for Debian distribs
  82. apt: name=python-apt state=latest update_cache=yes cache_valid_time=3600
  83. when: ansible_os_family == "Debian"
  84. tags: bootstrap-os
  85. - name: Install python-dnf for latest RedHat versions
  86. command: dnf install -y python-dnf yum
  87. when: ansible_distribution == "Fedora" and
  88. ansible_distribution_major_version > 21
  89. changed_when: False
  90. tags: bootstrap-os
  91. - name: Install epel-release on RedHat/CentOS
  92. shell: rpm -qa | grep epel-release || rpm -ivh {{ epel_rpm_download_url }}
  93. when: ansible_distribution in ["CentOS","RedHat"]
  94. changed_when: False
  95. tags: bootstrap-os
  96. - name: Install packages requirements
  97. action:
  98. module: "{{ ansible_pkg_mgr }}"
  99. name: "{{ item }}"
  100. state: latest
  101. register: pkgs_task_result
  102. until: pkgs_task_result|success
  103. retries: 4
  104. delay: "{{ retry_stagger | random + 3 }}"
  105. with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
  106. when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  107. tags: bootstrap-os
  108. # Todo : selinux configuration
  109. - name: Set selinux policy to permissive
  110. selinux: policy=targeted state=permissive
  111. when: ansible_os_family == "RedHat"
  112. changed_when: False
  113. tags: bootstrap-os
  114. - name: Disable IPv6 DNS lookup
  115. lineinfile:
  116. dest: /etc/gai.conf
  117. line: "precedence ::ffff:0:0/96 100"
  118. state: present
  119. backup: yes
  120. when: disable_ipv6_dns and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  121. tags: bootstrap-os
  122. - name: set default sysctl file path
  123. set_fact:
  124. sysctl_file_path: "/etc/sysctl.d/99-sysctl.conf"
  125. tags: bootstrap-os
  126. - name: Stat sysctl file configuration
  127. stat: path={{sysctl_file_path}}
  128. register: sysctl_file_stat
  129. tags: bootstrap-os
  130. - name: Change sysctl file path to link source if linked
  131. set_fact:
  132. sysctl_file_path: "{{sysctl_file_stat.stat.lnk_source}}"
  133. when: sysctl_file_stat.stat.islnk is defined and sysctl_file_stat.stat.islnk
  134. tags: bootstrap-os
  135. - name: Enable ip forwarding
  136. sysctl:
  137. sysctl_file: "{{sysctl_file_path}}"
  138. name: net.ipv4.ip_forward
  139. value: 1
  140. state: present
  141. tags: bootstrap-os
  142. - name: Write openstack cloud-config
  143. template:
  144. src: openstack-cloud-config.j2
  145. dest: "{{ kube_config_dir }}/cloud_config"
  146. group: "{{ kube_cert_group }}"
  147. mode: 0640
  148. when: inventory_hostname in groups['k8s-cluster'] and cloud_provider is defined and cloud_provider == "openstack"
  149. tags: [cloud-provider, openstack]
  150. - name: Write azure cloud-config
  151. template:
  152. src: azure-cloud-config.j2
  153. dest: "{{ kube_config_dir }}/cloud_config"
  154. group: "{{ kube_cert_group }}"
  155. mode: 0640
  156. when: inventory_hostname in groups['k8s-cluster'] and cloud_provider is defined and cloud_provider == "azure"
  157. tags: [cloud-provider, azure]
  158. - include: etchosts.yml
  159. tags: [bootstrap-os, etchosts]
  160. - include: resolvconf.yml
  161. when: dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
  162. tags: [bootstrap-os, resolvconf]
  163. - include: dhclient-hooks.yml
  164. when: dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  165. tags: [bootstrap-os, resolvconf]
  166. - include: dhclient-hooks-undo.yml
  167. when: dns_mode != 'none' and resolvconf_mode != 'host_resolvconf' and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  168. tags: [bootstrap-os, resolvconf]
  169. - name: Check if we are running inside a Azure VM
  170. stat: path=/var/lib/waagent/
  171. register: azure_check
  172. tags: bootstrap-os
  173. - include: growpart-azure-centos-7.yml
  174. when: azure_check.stat.exists and
  175. ansible_distribution in ["CentOS","RedHat"]
  176. tags: bootstrap-os