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.

155 lines
4.6 KiB

  1. ---
  2. - name: Force binaries directory for CoreOS
  3. set_fact:
  4. bin_dir: "/opt/bin"
  5. when: ansible_os_family == "CoreOS"
  6. - name: check bin dir exists
  7. file:
  8. path: "{{bin_dir}}"
  9. state: directory
  10. owner: root
  11. become: true
  12. - include: gitinfos.yml
  13. when: run_gitinfos
  14. - include: set_facts.yml
  15. - name: gather os specific variables
  16. include_vars: "{{ item }}"
  17. with_first_found:
  18. - files:
  19. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
  20. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
  21. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  22. - "{{ ansible_distribution|lower }}.yml"
  23. - "{{ ansible_os_family|lower }}.yml"
  24. - defaults.yml
  25. paths:
  26. - ../vars
  27. skip: true
  28. - name: Create kubernetes config directory
  29. file:
  30. path: "{{ kube_config_dir }}"
  31. state: directory
  32. owner: kube
  33. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  34. - name: Create kubernetes script directory
  35. file:
  36. path: "{{ kube_script_dir }}"
  37. state: directory
  38. owner: kube
  39. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  40. - name: Create kubernetes manifests directory
  41. file:
  42. path: "{{ kube_manifest_dir }}"
  43. state: directory
  44. owner: kube
  45. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  46. - name: Create kubernetes logs directory
  47. file:
  48. path: "{{ kube_log_dir }}"
  49. state: directory
  50. owner: kube
  51. when: ansible_service_mgr in ["sysvinit","upstart"] and "{{ inventory_hostname in groups['k8s-cluster'] }}"
  52. - name: check cloud_provider value
  53. fail:
  54. msg: "If set the 'cloud_provider' var must be set either to 'generic', 'gce', 'aws', 'azure' or 'openstack'"
  55. when: cloud_provider is defined and cloud_provider not in ['generic', 'gce', 'aws', 'openstack', 'azure']
  56. - include: openstack-credential-check.yml
  57. when: cloud_provider is defined and cloud_provider == 'openstack'
  58. - include: azure-credential-check.yml
  59. when: cloud_provider is defined and cloud_provider == 'azure'
  60. - name: Fix ipv4 forward rule in GCE security policy
  61. lineinfile:
  62. dest: /etc/sysctl.d/99-sysctl.conf
  63. regexp: '^net.ipv4.ip_forward='
  64. line: 'net.ipv4.ip_forward=1'
  65. state: present
  66. create: yes
  67. backup: yes
  68. validate: 'sysctl -f %s'
  69. when: cloud_provider is defined and cloud_provider == 'gce'
  70. - name: Create cni directories
  71. file:
  72. path: "{{ item }}"
  73. state: directory
  74. owner: kube
  75. with_items:
  76. - "/etc/cni/net.d"
  77. - "/opt/cni/bin"
  78. when: kube_network_plugin in ["calico", "weave", "canal"] and "{{ inventory_hostname in groups['k8s-cluster'] }}"
  79. - name: Update package management cache (YUM)
  80. yum: update_cache=yes name='*'
  81. when: ansible_pkg_mgr == 'yum'
  82. - name: Install latest version of python-apt for Debian distribs
  83. apt: name=python-apt state=latest update_cache=yes cache_valid_time=3600
  84. when: ansible_os_family == "Debian"
  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. - name: Install epel-release on RedHat/CentOS
  91. shell: rpm -qa | grep epel-release || rpm -ivh {{ epel_rpm_download_url }}
  92. when: ansible_distribution in ["CentOS","RedHat"] and
  93. ansible_distribution_major_version >= 7
  94. changed_when: False
  95. - name: Install packages requirements
  96. action:
  97. module: "{{ ansible_pkg_mgr }}"
  98. name: "{{ item }}"
  99. state: latest
  100. register: pkgs_task_result
  101. until: pkgs_task_result|success
  102. retries: 4
  103. delay: "{{ retry_stagger | random + 3 }}"
  104. with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
  105. when: ansible_os_family != "CoreOS"
  106. - name: Disable IPv6 DNS lookup
  107. lineinfile:
  108. dest: /etc/gai.conf
  109. line: "precedence ::ffff:0:0/96 100"
  110. state: present
  111. backup: yes
  112. when: disable_ipv6_dns and ansible_os_family != "CoreOS"
  113. # Todo : selinux configuration
  114. - name: Set selinux policy to permissive
  115. selinux: policy=targeted state=permissive
  116. when: ansible_os_family == "RedHat"
  117. changed_when: False
  118. - name: Write openstack cloud-config
  119. template:
  120. src: openstack-cloud-config.j2
  121. dest: "{{ kube_config_dir }}/cloud_config"
  122. group: "{{ kube_cert_group }}"
  123. mode: 0640
  124. when: cloud_provider is defined and cloud_provider == "openstack"
  125. - name: Write azure cloud-config
  126. template:
  127. src: azure-cloud-config.j2
  128. dest: "{{ kube_config_dir }}/cloud_config"
  129. group: "{{ kube_cert_group }}"
  130. mode: 0640
  131. when: cloud_provider is defined and cloud_provider == "azure"
  132. - include: etchosts.yml