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