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.

132 lines
4.2 KiB

  1. ---
  2. - name: check if fedora coreos
  3. stat:
  4. path: /run/ostree-booted
  5. register: ostree
  6. - name: set is_ostree
  7. set_fact:
  8. is_ostree: "{{ ostree.stat.exists }}"
  9. - name: Fail containerd setup if distribution is not supported
  10. fail:
  11. msg: "{{ ansible_distribution }} is not supported by containerd."
  12. when:
  13. - not ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian", "Fedora"]
  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|lower }}-{{ host_architecture }}.yml"
  20. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml"
  21. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  22. - "{{ ansible_distribution|lower }}-{{ host_architecture }}.yml"
  23. - "{{ ansible_distribution|lower }}.yml"
  24. - "{{ ansible_os_family|lower }}-{{ host_architecture }}.yml"
  25. - "{{ ansible_os_family|lower }}.yml"
  26. - defaults.yml
  27. paths:
  28. - ../vars
  29. skip: true
  30. tags:
  31. - facts
  32. - name: disable unified_cgroup_hierarchy in Fedora 31+
  33. command: grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"
  34. when:
  35. - ansible_distribution == "Fedora"
  36. - (ansible_distribution_major_version | int) >= 31
  37. - ansible_proc_cmdline['systemd.unified_cgroup_hierarchy'] is not defined or ansible_proc_cmdline['systemd.unified_cgroup_hierarchy'] != '0'
  38. - name: reboot in Fedora 31+
  39. reboot:
  40. when:
  41. - ansible_distribution == "Fedora"
  42. - (ansible_distribution_major_version | int) >= 31
  43. - ansible_proc_cmdline['systemd.unified_cgroup_hierarchy'] is not defined or ansible_proc_cmdline['systemd.unified_cgroup_hierarchy'] != '0'
  44. - include_tasks: containerd_repo.yml
  45. when: not is_ostree
  46. - name: Create containerd service systemd directory if it doesn't exist
  47. file:
  48. path: /etc/systemd/system/containerd.service.d
  49. state: directory
  50. - name: Write containerd proxy drop-in
  51. template:
  52. src: http-proxy.conf.j2
  53. dest: /etc/systemd/system/containerd.service.d/http-proxy.conf
  54. notify: restart containerd
  55. when: http_proxy is defined or https_proxy is defined
  56. - name: ensure containerd config directory
  57. file:
  58. dest: "{{ containerd_cfg_dir }}"
  59. state: directory
  60. mode: 0755
  61. owner: root
  62. group: root
  63. - name: Copy containerd config file
  64. template:
  65. src: config.toml.j2
  66. dest: "{{ containerd_cfg_dir }}/config.toml"
  67. owner: "root"
  68. mode: 0644
  69. notify: restart containerd
  70. # This is required to ensure any apt upgrade will not break kubernetes
  71. - name: Set containerd pin priority to apt_preferences on Debian family
  72. template:
  73. src: "apt_preferences.d/debian_containerd.j2"
  74. dest: "/etc/apt/preferences.d/containerd"
  75. owner: "root"
  76. mode: 0644
  77. when:
  78. - ansible_os_family in ['Ubuntu', 'Debian']
  79. - not is_ostree
  80. - name: ensure containerd packages are installed
  81. action: "{{ containerd_package_info.pkg_mgr }}"
  82. args:
  83. pkg: "{{ item.name }}"
  84. force: "{{ item.force | default(omit) }}"
  85. conf_file: "{{ item.yum_conf | default(omit) }}"
  86. state: present
  87. update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
  88. register: containerd_task_result
  89. until: containerd_task_result is succeeded
  90. retries: 4
  91. delay: "{{ retry_stagger | d(3) }}"
  92. with_items: "{{ containerd_package_info.pkgs }}"
  93. notify: restart containerd
  94. when:
  95. - not is_ostree
  96. - containerd_package_info.pkgs|length > 0
  97. ignore_errors: true
  98. - name: Check if runc is installed
  99. stat:
  100. path: "{{ runc_binary }}"
  101. register: runc_stat
  102. - name: Install runc package if necessary
  103. action: "{{ containerd_package_info.pkg_mgr }}"
  104. args:
  105. pkg: runc
  106. state: present
  107. update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
  108. register: runc_task_result
  109. until: runc_task_result is succeeded
  110. retries: 4
  111. delay: "{{ retry_stagger | d(3) }}"
  112. notify: restart containerd
  113. when:
  114. - not is_ostree
  115. - not runc_stat.stat.exists
  116. - include_tasks: crictl.yml