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.

95 lines
2.9 KiB

  1. ---
  2. - name: Fail containerd setup if distribution is not supported
  3. fail:
  4. msg: "{{ ansible_distribution }} is not supported by containerd."
  5. when:
  6. - not ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian"]
  7. - name: gather os specific variables
  8. include_vars: "{{ item }}"
  9. with_first_found:
  10. - files:
  11. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
  12. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}-{{ host_architecture }}.yml"
  13. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml"
  14. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  15. - "{{ ansible_distribution|lower }}-{{ host_architecture }}.yml"
  16. - "{{ ansible_distribution|lower }}.yml"
  17. - "{{ ansible_os_family|lower }}-{{ host_architecture }}.yml"
  18. - "{{ ansible_os_family|lower }}.yml"
  19. - defaults.yml
  20. paths:
  21. - ../vars
  22. skip: true
  23. tags:
  24. - facts
  25. - include_tasks: containerd_repo.yml
  26. - name: ensure containerd config directory
  27. file:
  28. dest: "{{ containerd_cfg_dir }}"
  29. state: directory
  30. mode: 0755
  31. owner: root
  32. group: root
  33. - name: Copy containerd config file
  34. template:
  35. src: config.toml.j2
  36. dest: "{{ containerd_cfg_dir }}/config.toml"
  37. owner: "root"
  38. mode: 0644
  39. notify: restart containerd
  40. # This is required to ensure any apt upgrade will not break kubernetes
  41. - name: Set containerd pin priority to apt_preferences on Debian family
  42. template:
  43. src: "apt_preferences.d/debian_containerd.j2"
  44. dest: "/etc/apt/preferences.d/containerd"
  45. owner: "root"
  46. mode: 0644
  47. when:
  48. - ansible_os_family in ['Ubuntu', 'Debian']
  49. - not is_atomic
  50. - name: ensure containerd packages are installed
  51. action: "{{ containerd_package_info.pkg_mgr }}"
  52. args:
  53. pkg: "{{ item.name }}"
  54. force: "{{ item.force | default(omit) }}"
  55. conf_file: "{{ item.yum_conf | default(omit) }}"
  56. state: present
  57. update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
  58. register: containerd_task_result
  59. until: containerd_task_result is succeeded
  60. retries: 4
  61. delay: "{{ retry_stagger | d(3) }}"
  62. with_items: "{{ containerd_package_info.pkgs }}"
  63. notify: restart containerd
  64. when:
  65. - not is_atomic
  66. - containerd_package_info.pkgs|length > 0
  67. ignore_errors: true
  68. - name: Check if runc is installed
  69. stat:
  70. path: "{{ runc_binary }}"
  71. register: runc_stat
  72. - name: Install runc package if necessary
  73. action: "{{ containerd_package_info.pkg_mgr }}"
  74. args:
  75. pkg: runc
  76. state: present
  77. update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
  78. register: runc_task_result
  79. until: runc_task_result is succeeded
  80. retries: 4
  81. delay: "{{ retry_stagger | d(3) }}"
  82. notify: restart containerd
  83. when:
  84. - not is_atomic
  85. - not runc_stat.stat.exists
  86. - include_tasks: crictl.yml