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.

146 lines
3.7 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  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: gather os specific variables
  10. include_vars: "{{ item }}"
  11. with_first_found:
  12. - files:
  13. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
  14. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
  15. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  16. - "{{ ansible_distribution|lower }}.yml"
  17. - "{{ ansible_os_family|lower }}-{{ ansible_architecture }}.yml"
  18. - "{{ ansible_os_family|lower }}.yml"
  19. - defaults.yml
  20. paths:
  21. - ../vars
  22. skip: true
  23. tags:
  24. - facts
  25. - import_tasks: "crio_repo.yml"
  26. - import_tasks: "crictl.yml"
  27. - name: Make sure needed folders exist in the system
  28. with_items:
  29. - /etc/crio
  30. - /etc/containers
  31. - /etc/systemd/system/crio.service.d
  32. file:
  33. path: "{{ item }}"
  34. state: directory
  35. - name: Install cri-o packages
  36. package:
  37. name: "{{ item }}"
  38. state: present
  39. when: not is_ostree
  40. with_items: "{{ crio_packages }}"
  41. register: package_install
  42. until: package_install is succeeded
  43. retries: 4
  44. delay: "{{ retry_stagger | d(3) }}"
  45. - name: Gather the rpm package facts
  46. package_facts:
  47. manager: auto
  48. when:
  49. - ansible_distribution == "CentOS"
  50. - ansible_distribution_major_version == "8"
  51. - name: Ensure latest version of libseccom installed # noqa 303
  52. command: "yum update -y libseccomp"
  53. when:
  54. - ansible_distribution == "CentOS"
  55. - ansible_distribution_major_version == "8"
  56. - ansible_facts.packages['libseccomp'] | map(attribute='version') | map('regex_replace','^(?P<major>\\d+).(?P<minor>\\d+).(?P<patch>\\d+)$', '\\g<major>.\\g<minor>') | list | first == '2.3'
  57. notify: restart crio
  58. - name: Check if already installed
  59. stat:
  60. path: "/bin/crio"
  61. register: need_bootstrap_crio
  62. when: is_ostree
  63. - name: Install cri-o packages with osttree
  64. command: "rpm-ostree install {{ crio_packages|join(' ') }}"
  65. when:
  66. - is_ostree
  67. - not need_bootstrap_crio.stat.exists
  68. become: true
  69. - name: Reboot immediately for updated ostree
  70. reboot:
  71. become: true
  72. when:
  73. - is_ostree
  74. - not need_bootstrap_crio.stat.exists
  75. - name: Remove example CNI configs
  76. file:
  77. path: "/etc/cni/net.d/{{ item }}"
  78. state: absent
  79. loop:
  80. - 100-crio-bridge.conf
  81. - 200-loopback.conf
  82. - name: Install cri-o config
  83. template:
  84. src: crio.conf.j2
  85. dest: /etc/crio/crio.conf
  86. notify: restart crio
  87. - name: Copy mounts.conf
  88. copy:
  89. src: mounts.conf
  90. dest: /etc/containers/mounts.conf
  91. when:
  92. - ansible_os_family == 'RedHat'
  93. notify: restart crio
  94. - name: Create directory for oci hooks
  95. file:
  96. path: /etc/containers/oci/hooks.d
  97. state: directory
  98. owner: root
  99. mode: 0755
  100. - name: Remove metacopy mount options for older kernels
  101. ini_file:
  102. dest: /etc/containers/storage.conf
  103. section: storage.options.overlay
  104. option: mountopt
  105. value: "\"nodev\""
  106. when:
  107. - ansible_distribution == "CentOS"
  108. - ansible_distribution_major_version == "7"
  109. - name: Write cri-o proxy drop-in
  110. template:
  111. src: http-proxy.conf.j2
  112. dest: /etc/systemd/system/crio.service.d/http-proxy.conf
  113. notify: restart crio
  114. when: http_proxy is defined or https_proxy is defined
  115. - name: Ensure crio service is started and enabled
  116. service:
  117. name: crio
  118. daemon_reload: true
  119. enabled: true
  120. state: started
  121. - name: Verify that crio is running
  122. command: "crio-status info"
  123. register: get_crio_info
  124. until: get_crio_info is succeeded
  125. changed_when: false
  126. retries: 5
  127. delay: "{{ retry_stagger | random + 3 }}"