systemcontainer_crio.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 | bool
  6. - set_fact:
  7. l_crio_registries: "{{ l2_docker_additional_registries + ['docker.io'] }}"
  8. when: l2_docker_additional_registries | bool
  9. - set_fact:
  10. l_crio_registries: "{{ ['docker.io'] }}"
  11. when: not (l2_docker_additional_registries | bool)
  12. - set_fact:
  13. l_additional_crio_registries: "{{ '\"{}\"'.format('\", \"'.join(l_crio_registries)) }}"
  14. when: l2_docker_additional_registries | bool
  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. failed_when: false
  56. - when: l_has_overlay_in_kernel.rc != 0
  57. block:
  58. - name: Add overlay to modprobe.d
  59. template:
  60. dest: /etc/modules-load.d/overlay.conf
  61. src: overlay.conf.j2
  62. backup: yes
  63. - name: Manually modprobe overlay into the kernel
  64. command: modprobe overlay
  65. - name: Enable and start systemd-modules-load
  66. service:
  67. name: systemd-modules-load
  68. enabled: yes
  69. state: restarted
  70. - name: Ensure proxies are in the atomic.conf
  71. include_role:
  72. name: openshift_atomic
  73. tasks_from: proxy
  74. - block:
  75. - name: Set CRI-O image defaults
  76. set_fact:
  77. l_crio_image_prepend: "docker.io/gscrivano"
  78. l_crio_image_name: "cri-o-fedora"
  79. l_crio_image_tag: "latest"
  80. - name: Use Centos based image when distribution is CentOS
  81. set_fact:
  82. l_crio_image_name: "cri-o-centos"
  83. when: ansible_distribution == "CentOS"
  84. - name: Set CRI-O image tag
  85. set_fact:
  86. l_crio_image_tag: "{{ l_openshift_image_tag }}"
  87. when:
  88. - openshift_deployment_type == 'openshift-enterprise'
  89. - name: Use RHEL based image when distribution is Red Hat
  90. set_fact:
  91. l_crio_image_prepend: "registry.access.redhat.com/openshift3"
  92. l_crio_image_name: "cri-o"
  93. when: ansible_distribution == "RedHat"
  94. - name: Set the full image name
  95. set_fact:
  96. l_crio_image: "{{ l_crio_image_prepend }}/{{ l_crio_image_name }}:{{ l_crio_image_tag }}"
  97. # For https://github.com/openshift/aos-cd-jobs/pull/624#pullrequestreview-61816548
  98. - name: Use a specific image if requested
  99. set_fact:
  100. l_crio_image: "{{ openshift_crio_systemcontainer_image_override }}"
  101. when:
  102. - openshift_crio_systemcontainer_image_override is defined
  103. - openshift_crio_systemcontainer_image_override != ""
  104. # Be nice and let the user see the variable result
  105. - debug:
  106. var: l_crio_image
  107. # NOTE: no_proxy added as a workaround until https://github.com/projectatomic/atomic/pull/999 is released
  108. - name: Pre-pull CRI-O System Container image
  109. command: "atomic pull --storage ostree {{ l_crio_image }}"
  110. changed_when: false
  111. environment:
  112. NO_PROXY: "{{ openshift.common.no_proxy | default('') }}"
  113. - name: Install CRI-O System Container
  114. oc_atomic_container:
  115. name: "cri-o"
  116. image: "{{ l_crio_image }}"
  117. state: latest
  118. - name: Remove CRI-O default configuration files
  119. file:
  120. path: "{{ item }}"
  121. state: absent
  122. with_items:
  123. - /etc/cni/net.d/200-loopback.conf
  124. - /etc/cni/net.d/100-crio-bridge.conf
  125. - name: Create the CRI-O configuration
  126. template:
  127. dest: /etc/crio/crio.conf
  128. src: crio.conf.j2
  129. backup: yes
  130. - name: Ensure CNI configuration directory exists
  131. file:
  132. path: /etc/cni/net.d/
  133. state: directory
  134. - name: setup firewall for CRI-O
  135. include: crio_firewall.yml
  136. static: yes
  137. - name: Configure the CNI network
  138. template:
  139. dest: /etc/cni/net.d/openshift-sdn.conf
  140. src: 80-openshift-sdn.conf.j2
  141. - name: Start the CRI-O service
  142. systemd:
  143. name: "cri-o"
  144. enabled: yes
  145. state: started
  146. daemon_reload: yes
  147. register: start_result
  148. - meta: flush_handlers
  149. # If we are using crio only, docker.service might not be available for
  150. # 'docker login'
  151. - include: registry_auth.yml
  152. vars:
  153. openshift_docker_alternative_creds: "{{ l_use_crio_only }}"