systemcontainer_crio.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. - block:
  70. - name: Add http_proxy to /etc/atomic.conf
  71. lineinfile:
  72. dest: /etc/atomic.conf
  73. regexp: "^#?http_proxy[:=]{1}"
  74. line: "http_proxy: {{ openshift.common.http_proxy | default('') }}"
  75. when:
  76. - openshift.common.http_proxy is defined
  77. - openshift.common.http_proxy != ''
  78. - name: Add https_proxy to /etc/atomic.conf
  79. lineinfile:
  80. dest: /etc/atomic.conf
  81. regexp: "^#?https_proxy[:=]{1}"
  82. line: "https_proxy: {{ openshift.common.https_proxy | default('') }}"
  83. when:
  84. - openshift.common.https_proxy is defined
  85. - openshift.common.https_proxy != ''
  86. - name: Add no_proxy to /etc/atomic.conf
  87. lineinfile:
  88. dest: /etc/atomic.conf
  89. regexp: "^#?no_proxy[:=]{1}"
  90. line: "no_proxy: {{ openshift.common.no_proxy | default('') }}"
  91. when:
  92. - openshift.common.no_proxy is defined
  93. - openshift.common.no_proxy != ''
  94. - block:
  95. - name: Set CRI-O image defaults
  96. set_fact:
  97. l_crio_image_prepend: "docker.io/gscrivano"
  98. l_crio_image_name: "cri-o-fedora"
  99. l_crio_image_tag: "latest"
  100. - name: Use Centos based image when distribution is CentOS
  101. set_fact:
  102. l_crio_image_name: "cri-o-centos"
  103. when: ansible_distribution == "CentOS"
  104. - name: Set CRI-O image tag
  105. set_fact:
  106. l_crio_image_tag: "{{ l_openshift_image_tag }}"
  107. when:
  108. - openshift_deployment_type == 'openshift-enterprise'
  109. - name: Use RHEL based image when distribution is Red Hat
  110. set_fact:
  111. l_crio_image_prepend: "registry.access.redhat.com/openshift3"
  112. l_crio_image_name: "cri-o"
  113. when: ansible_distribution == "RedHat"
  114. - name: Set the full image name
  115. set_fact:
  116. l_crio_image: "{{ l_crio_image_prepend }}/{{ l_crio_image_name }}:{{ l_crio_image_tag }}"
  117. # For https://github.com/openshift/aos-cd-jobs/pull/624#pullrequestreview-61816548
  118. - name: Use a specific image if requested
  119. set_fact:
  120. l_crio_image: "{{ openshift_crio_systemcontainer_image_override }}"
  121. when:
  122. - openshift_crio_systemcontainer_image_override is defined
  123. - openshift_crio_systemcontainer_image_override != ""
  124. # Be nice and let the user see the variable result
  125. - debug:
  126. var: l_crio_image
  127. # NOTE: no_proxy added as a workaround until https://github.com/projectatomic/atomic/pull/999 is released
  128. - name: Pre-pull CRI-O System Container image
  129. command: "atomic pull --storage ostree {{ l_crio_image }}"
  130. changed_when: false
  131. environment:
  132. NO_PROXY: "{{ openshift.common.no_proxy | default('') }}"
  133. - name: Install CRI-O System Container
  134. oc_atomic_container:
  135. name: "cri-o"
  136. image: "{{ l_crio_image }}"
  137. state: latest
  138. - name: Remove CRI-O default configuration files
  139. file:
  140. path: "{{ item }}"
  141. state: absent
  142. with_items:
  143. - /etc/cni/net.d/200-loopback.conf
  144. - /etc/cni/net.d/100-crio-bridge.conf
  145. - name: Create the CRI-O configuration
  146. template:
  147. dest: /etc/crio/crio.conf
  148. src: crio.conf.j2
  149. backup: yes
  150. - name: Ensure CNI configuration directory exists
  151. file:
  152. path: /etc/cni/net.d/
  153. state: directory
  154. - name: Configure the CNI network
  155. template:
  156. dest: /etc/cni/net.d/openshift-sdn.conf
  157. src: 80-openshift-sdn.conf.j2
  158. - name: Start the CRI-O service
  159. systemd:
  160. name: "cri-o"
  161. enabled: yes
  162. state: started
  163. daemon_reload: yes
  164. register: start_result
  165. - meta: flush_handlers