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.

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