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.

122 lines
3.8 KiB

  1. ---
  2. - include: gitinfos.yml
  3. when: run_gitinfos
  4. - include: set_facts.yml
  5. - name: gather os specific variables
  6. include_vars: "{{ item }}"
  7. with_first_found:
  8. - files:
  9. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
  10. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
  11. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  12. - "{{ ansible_distribution|lower }}.yml"
  13. - "{{ ansible_os_family|lower }}.yml"
  14. - defaults.yml
  15. paths:
  16. - ../vars
  17. skip: true
  18. - name: Force binaries directory for CoreOS
  19. set_fact:
  20. bin_dir: "/opt/bin"
  21. when: ansible_os_family == "CoreOS"
  22. - name: Create kubernetes config directory
  23. file:
  24. path: "{{ kube_config_dir }}"
  25. state: directory
  26. owner: kube
  27. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  28. - name: Create kubernetes script directory
  29. file:
  30. path: "{{ kube_script_dir }}"
  31. state: directory
  32. owner: kube
  33. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  34. - name: Create kubernetes manifests directory
  35. file:
  36. path: "{{ kube_manifest_dir }}"
  37. state: directory
  38. owner: kube
  39. when: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  40. - name: Create kubernetes logs directory
  41. file:
  42. path: "{{ kube_log_dir }}"
  43. state: directory
  44. owner: kube
  45. when: ansible_service_mgr in ["sysvinit","upstart"] and "{{ inventory_hostname in groups['k8s-cluster'] }}"
  46. - name: check cloud_provider value
  47. fail:
  48. msg: "If set the 'cloud_provider' var must be set either to 'generic', 'gce', 'aws' or 'openstack'"
  49. when: cloud_provider is defined and cloud_provider not in ['generic', 'gce', 'aws', 'openstack']
  50. - include: openstack-credential-check.yml
  51. when: cloud_provider is defined and cloud_provider == 'openstack'
  52. - name: Create cni directories
  53. file:
  54. path: "{{ item }}"
  55. state: directory
  56. owner: kube
  57. with_items:
  58. - "/etc/cni/net.d"
  59. - "/opt/cni/bin"
  60. when: kube_network_plugin in ["calico", "weave"] and "{{ inventory_hostname in groups['k8s-cluster'] }}"
  61. - name: Update package management cache (YUM)
  62. yum: update_cache=yes name='*'
  63. when: ansible_pkg_mgr == 'yum'
  64. - name: Install latest version of python-apt for Debian distribs
  65. apt: name=python-apt state=latest update_cache=yes cache_valid_time=3600
  66. when: ansible_os_family == "Debian"
  67. - name: Install python-dnf for latest RedHat versions
  68. command: dnf install -y python-dnf yum
  69. when: ansible_distribution == "Fedora" and
  70. ansible_distribution_major_version > 21
  71. changed_when: False
  72. - name: Install epel-release on RedHat/CentOS
  73. shell: rpm -qa | grep epel-release || rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  74. when: ansible_distribution in ["CentOS","RedHat"] and
  75. ansible_distribution_major_version >= 7
  76. changed_when: False
  77. - name: Install packages requirements
  78. action:
  79. module: "{{ ansible_pkg_mgr }}"
  80. name: "{{ item }}"
  81. state: latest
  82. with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
  83. when: ansible_os_family != "CoreOS"
  84. - name: Disable IPv6 DNS lookup
  85. lineinfile:
  86. dest: /etc/gai.conf
  87. line: "precedence ::ffff:0:0/96 100"
  88. state: present
  89. backup: yes
  90. when: disable_ipv6_dns and ansible_os_family != "CoreOS"
  91. # Todo : selinux configuration
  92. - name: Set selinux policy to permissive
  93. selinux: policy=targeted state=permissive
  94. when: ansible_os_family == "RedHat"
  95. changed_when: False
  96. - name: Write openstack cloud-config
  97. template:
  98. src: openstack-cloud-config.j2
  99. dest: "{{ kube_config_dir }}/cloud_config"
  100. group: "{{ kube_cert_group }}"
  101. mode: 0640
  102. when: cloud_provider is defined and cloud_provider == "openstack"
  103. - include: etchosts.yml