systemcontainer_crio.yml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. ---
  2. # TODO: Much of this file is shared with container engine tasks
  3. - set_fact:
  4. l_insecure_crio_registries: "{{ '\"{}\"'.format('\", \"'.join(l2_docker_insecure_registries)) }}"
  5. when: l2_docker_insecure_registries
  6. - set_fact:
  7. l_crio_registries: "{{ l2_docker_additional_registries + ['docker.io'] }}"
  8. when: l2_docker_additional_registries
  9. - set_fact:
  10. l_crio_registries: "{{ ['docker.io'] }}"
  11. when: not l2_docker_additional_registries
  12. - set_fact:
  13. l_additional_crio_registries: "{{ '\"{}\"'.format('\", \"'.join(l_crio_registries)) }}"
  14. when: l2_docker_additional_registries
  15. - set_fact:
  16. l_openshift_image_tag: "{{ openshift_image_tag | string }}"
  17. when: openshift_image_tag is defined
  18. - set_fact:
  19. l_openshift_image_tag: "latest"
  20. when:
  21. - openshift_image_tag is not defined
  22. - openshift_release == "latest"
  23. - set_fact:
  24. l_openshift_image_tag: "{{ openshift_release | string }}"
  25. when:
  26. - openshift_image_tag is not defined
  27. - openshift_release != "latest"
  28. - name: Ensure container-selinux is installed
  29. package:
  30. name: container-selinux
  31. state: present
  32. when: not openshift.common.is_atomic | bool
  33. - name: Check we are not using node as a Docker container with CRI-O
  34. fail: msg='Cannot use CRI-O with node configured as a Docker container'
  35. when:
  36. - openshift.common.is_containerized | bool
  37. - not openshift.common.is_node_system_container | bool
  38. # Used to pull and install the system container
  39. - name: Ensure atomic is installed
  40. package:
  41. name: atomic
  42. state: present
  43. when: not openshift.common.is_atomic | bool
  44. # At the time of writing the atomic command requires runc for it's own use. This
  45. # task is here in the even that the atomic package ever removes the dependency.
  46. - name: Ensure runc is installed
  47. package:
  48. name: runc
  49. state: present
  50. when: not openshift.common.is_atomic | bool
  51. - name: Check that overlay is in the kernel
  52. shell: lsmod | grep overlay
  53. register: l_has_overlay_in_kernel
  54. ignore_errors: yes
  55. - when: l_has_overlay_in_kernel.rc != 0
  56. block:
  57. - name: Add overlay to modprobe.d
  58. template:
  59. dest: /etc/modules-load.d/overlay.conf
  60. src: overlay.conf.j2
  61. backup: yes
  62. - name: Manually modprobe overlay into the kernel
  63. command: modprobe overlay
  64. - name: Enable and start systemd-modules-load
  65. service:
  66. name: systemd-modules-load
  67. enabled: yes
  68. state: restarted
  69. - name: Ensure proxies are in the atomic.conf
  70. include_role:
  71. name: openshift_atomic
  72. tasks_from: proxy
  73. - block:
  74. - name: Set CRI-O image defaults
  75. set_fact:
  76. l_crio_image_prepend: "docker.io/gscrivano"
  77. l_crio_image_name: "cri-o-fedora"
  78. l_crio_image_tag: "latest"
  79. - name: Use Centos based image when distribution is CentOS
  80. set_fact:
  81. l_crio_image_name: "cri-o-centos"
  82. when: ansible_distribution == "CentOS"
  83. - name: Set CRI-O image tag
  84. set_fact:
  85. l_crio_image_tag: "{{ l_openshift_image_tag }}"
  86. when:
  87. - openshift_deployment_type == 'openshift-enterprise'
  88. - name: Use RHEL based image when distribution is Red Hat
  89. set_fact:
  90. l_crio_image_prepend: "registry.access.redhat.com/openshift3"
  91. l_crio_image_name: "cri-o"
  92. when: ansible_distribution == "RedHat"
  93. - name: Set the full image name
  94. set_fact:
  95. l_crio_image: "{{ l_crio_image_prepend }}/{{ l_crio_image_name }}:{{ l_crio_image_tag }}"
  96. # For https://github.com/openshift/aos-cd-jobs/pull/624#pullrequestreview-61816548
  97. - name: Use a specific image if requested
  98. set_fact:
  99. l_crio_image: "{{ openshift_crio_systemcontainer_image_override }}"
  100. when:
  101. - openshift_crio_systemcontainer_image_override is defined
  102. - openshift_crio_systemcontainer_image_override != ""
  103. # Be nice and let the user see the variable result
  104. - debug:
  105. var: l_crio_image
  106. # NOTE: no_proxy added as a workaround until https://github.com/projectatomic/atomic/pull/999 is released
  107. - name: Pre-pull CRI-O System Container image
  108. command: "atomic pull --storage ostree {{ l_crio_image }}"
  109. changed_when: false
  110. environment:
  111. NO_PROXY: "{{ openshift.common.no_proxy | default('') }}"
  112. - name: Install CRI-O System Container
  113. oc_atomic_container:
  114. name: "cri-o"
  115. image: "{{ l_crio_image }}"
  116. state: latest
  117. - name: Remove CRI-O default configuration files
  118. file:
  119. path: "{{ item }}"
  120. state: absent
  121. with_items:
  122. - /etc/cni/net.d/200-loopback.conf
  123. - /etc/cni/net.d/100-crio-bridge.conf
  124. - name: Create the CRI-O configuration
  125. template:
  126. dest: /etc/crio/crio.conf
  127. src: crio.conf.j2
  128. backup: yes
  129. - name: Ensure CNI configuration directory exists
  130. file:
  131. path: /etc/cni/net.d/
  132. state: directory
  133. - name: Configure the CNI network
  134. template:
  135. dest: /etc/cni/net.d/openshift-sdn.conf
  136. src: 80-openshift-sdn.conf.j2
  137. - name: Fix SELinux Permissions on /var/lib/containers
  138. command: "restorecon -R /var/lib/containers/"
  139. changed_when: false
  140. - name: Start the CRI-O service
  141. systemd:
  142. name: "cri-o"
  143. enabled: yes
  144. state: started
  145. daemon_reload: yes
  146. register: start_result
  147. - meta: flush_handlers