systemcontainer_crio.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. # Used to pull and install the system container
  34. - name: Ensure atomic is installed
  35. package:
  36. name: atomic
  37. state: present
  38. when: not openshift.common.is_atomic | bool
  39. # At the time of writing the atomic command requires runc for it's own use. This
  40. # task is here in the even that the atomic package ever removes the dependency.
  41. - name: Ensure runc is installed
  42. package:
  43. name: runc
  44. state: present
  45. when: not openshift.common.is_atomic | bool
  46. - name: Check that overlay is in the kernel
  47. shell: lsmod | grep overlay
  48. register: l_has_overlay_in_kernel
  49. ignore_errors: yes
  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. - block:
  65. - name: Add http_proxy to /etc/atomic.conf
  66. lineinfile:
  67. dest: /etc/atomic.conf
  68. regexp: "^#?http_proxy[:=]{1}"
  69. line: "http_proxy: {{ openshift.common.http_proxy | default('') }}"
  70. when:
  71. - openshift.common.http_proxy is defined
  72. - openshift.common.http_proxy != ''
  73. - name: Add https_proxy to /etc/atomic.conf
  74. lineinfile:
  75. dest: /etc/atomic.conf
  76. regexp: "^#?https_proxy[:=]{1}"
  77. line: "https_proxy: {{ openshift.common.https_proxy | default('') }}"
  78. when:
  79. - openshift.common.https_proxy is defined
  80. - openshift.common.https_proxy != ''
  81. - name: Add no_proxy to /etc/atomic.conf
  82. lineinfile:
  83. dest: /etc/atomic.conf
  84. regexp: "^#?no_proxy[:=]{1}"
  85. line: "no_proxy: {{ openshift.common.no_proxy | default('') }}"
  86. when:
  87. - openshift.common.no_proxy is defined
  88. - openshift.common.no_proxy != ''
  89. - block:
  90. - name: Set CRI-O image defaults
  91. set_fact:
  92. l_crio_image_prepend: "docker.io/gscrivano"
  93. l_crio_image_name: "cri-o-fedora"
  94. l_crio_image_tag: "latest"
  95. - name: Use Centos based image when distribution is CentOS
  96. set_fact:
  97. l_crio_image_name: "cri-o-centos"
  98. when: ansible_distribution == "CentOS"
  99. - name: Set CRI-O image tag
  100. set_fact:
  101. l_crio_image_tag: "{{ l_openshift_image_tag }}"
  102. when:
  103. - openshift_deployment_type == 'openshift-enterprise'
  104. - name: Use RHEL based image when distribution is Red Hat
  105. set_fact:
  106. l_crio_image_prepend: "registry.access.redhat.com/openshift3"
  107. l_crio_image_name: "cri-o"
  108. when: ansible_distribution == "RedHat"
  109. - name: Set the full image name
  110. set_fact:
  111. l_crio_image: "{{ l_crio_image_prepend }}/{{ l_crio_image_name }}:{{ l_crio_image_tag }}"
  112. # For https://github.com/openshift/aos-cd-jobs/pull/624#pullrequestreview-61816548
  113. - name: Use a specific image if requested
  114. set_fact:
  115. l_crio_image: "{{ openshift_crio_systemcontainer_image_override }}"
  116. when:
  117. - openshift_crio_systemcontainer_image_override is defined
  118. - openshift_crio_systemcontainer_image_override != ""
  119. # Be nice and let the user see the variable result
  120. - debug:
  121. var: l_crio_image
  122. # NOTE: no_proxy added as a workaround until https://github.com/projectatomic/atomic/pull/999 is released
  123. - name: Pre-pull CRI-O System Container image
  124. command: "atomic pull --storage ostree {{ l_crio_image }}"
  125. changed_when: false
  126. environment:
  127. NO_PROXY: "{{ openshift.common.no_proxy | default('') }}"
  128. - name: Install CRI-O System Container
  129. oc_atomic_container:
  130. name: "cri-o"
  131. image: "{{ l_crio_image }}"
  132. state: latest
  133. - name: Remove CRI-O default configuration files
  134. file:
  135. path: "{{ item }}"
  136. state: absent
  137. with_items:
  138. - /etc/cni/net.d/200-loopback.conf
  139. - /etc/cni/net.d/100-crio-bridge.conf
  140. - name: Create the CRI-O configuration
  141. template:
  142. dest: /etc/crio/crio.conf
  143. src: crio.conf.j2
  144. backup: yes
  145. - name: Ensure CNI configuration directory exists
  146. file:
  147. path: /etc/cni/net.d/
  148. state: directory
  149. - name: Configure the CNI network
  150. template:
  151. dest: /etc/cni/net.d/openshift-sdn.conf
  152. src: 80-openshift-sdn.conf.j2
  153. - name: Start the CRI-O service
  154. systemd:
  155. name: "cri-o"
  156. enabled: yes
  157. state: started
  158. daemon_reload: yes
  159. register: start_result
  160. - meta: flush_handlers