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.

215 lines
6.6 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. check_mode: no
  96. tags: bootstrap-os
  97. - name: Install packages requirements
  98. action:
  99. module: "{{ ansible_pkg_mgr }}"
  100. name: "{{ item }}"
  101. state: latest
  102. register: pkgs_task_result
  103. until: pkgs_task_result|success
  104. retries: 4
  105. delay: "{{ retry_stagger | random + 3 }}"
  106. with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
  107. when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  108. tags: bootstrap-os
  109. # Todo : selinux configuration
  110. - name: Confirm selinux deployed
  111. stat:
  112. path: /etc/selinux/config
  113. when: ansible_os_family == "RedHat"
  114. register: slc
  115. - name: Set selinux policy to permissive
  116. selinux: policy=targeted state=permissive
  117. when: ansible_os_family == "RedHat" and slc.stat.exists == True
  118. changed_when: False
  119. tags: bootstrap-os
  120. - name: Disable IPv6 DNS lookup
  121. lineinfile:
  122. dest: /etc/gai.conf
  123. line: "precedence ::ffff:0:0/96 100"
  124. state: present
  125. backup: yes
  126. when: disable_ipv6_dns and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  127. tags: bootstrap-os
  128. - name: set default sysctl file path
  129. set_fact:
  130. sysctl_file_path: "/etc/sysctl.d/99-sysctl.conf"
  131. tags: bootstrap-os
  132. - name: Stat sysctl file configuration
  133. stat: path={{sysctl_file_path}}
  134. register: sysctl_file_stat
  135. tags: bootstrap-os
  136. - name: Change sysctl file path to link source if linked
  137. set_fact:
  138. sysctl_file_path: "{{sysctl_file_stat.stat.lnk_source}}"
  139. when: sysctl_file_stat.stat.islnk is defined and sysctl_file_stat.stat.islnk
  140. tags: bootstrap-os
  141. - name: Enable ip forwarding
  142. sysctl:
  143. sysctl_file: "{{sysctl_file_path}}"
  144. name: net.ipv4.ip_forward
  145. value: 1
  146. state: present
  147. tags: bootstrap-os
  148. - name: Write openstack cloud-config
  149. template:
  150. src: openstack-cloud-config.j2
  151. dest: "{{ kube_config_dir }}/cloud_config"
  152. group: "{{ kube_cert_group }}"
  153. mode: 0640
  154. when: inventory_hostname in groups['k8s-cluster'] and cloud_provider is defined and cloud_provider == "openstack"
  155. tags: [cloud-provider, openstack]
  156. - name: Write azure cloud-config
  157. template:
  158. src: azure-cloud-config.j2
  159. dest: "{{ kube_config_dir }}/cloud_config"
  160. group: "{{ kube_cert_group }}"
  161. mode: 0640
  162. when: inventory_hostname in groups['k8s-cluster'] and cloud_provider is defined and cloud_provider == "azure"
  163. tags: [cloud-provider, azure]
  164. - include: etchosts.yml
  165. tags: [bootstrap-os, etchosts]
  166. - include: resolvconf.yml
  167. when: dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
  168. tags: [bootstrap-os, resolvconf]
  169. - include: dhclient-hooks.yml
  170. when: dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  171. tags: [bootstrap-os, resolvconf]
  172. - include: dhclient-hooks-undo.yml
  173. when: dns_mode != 'none' and resolvconf_mode != 'host_resolvconf' and not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  174. tags: [bootstrap-os, resolvconf]
  175. - name: Check if we are running inside a Azure VM
  176. stat: path=/var/lib/waagent/
  177. register: azure_check
  178. tags: bootstrap-os
  179. - include: growpart-azure-centos-7.yml
  180. when: azure_check.stat.exists and
  181. ansible_distribution in ["CentOS","RedHat"]
  182. tags: bootstrap-os