systemcontainer_crio.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. ---
  2. # TODO: Much of this file is shared with container engine tasks
  3. - set_fact:
  4. l_insecure_crio_registries: "{{ '\"{}\"'.format('\", \"'.join(openshift.docker.insecure_registries)) }}"
  5. when: openshift.docker.insecure_registries
  6. - name: Ensure container-selinux is installed
  7. package:
  8. name: container-selinux
  9. state: present
  10. when: not openshift.common.is_atomic | bool
  11. # Used to pull and install the system container
  12. - name: Ensure atomic is installed
  13. package:
  14. name: atomic
  15. state: present
  16. when: not openshift.common.is_atomic | bool
  17. # At the time of writing the atomic command requires runc for it's own use. This
  18. # task is here in the even that the atomic package ever removes the dependency.
  19. - name: Ensure runc is installed
  20. package:
  21. name: runc
  22. state: present
  23. when: not openshift.common.is_atomic | bool
  24. - name: Check that overlay is in the kernel
  25. shell: lsmod | grep overlay
  26. register: l_has_overlay_in_kernel
  27. ignore_errors: yes
  28. - when: l_has_overlay_in_kernel.rc != 0
  29. block:
  30. - name: Add overlay to modprobe.d
  31. template:
  32. dest: /etc/modules-load.d/overlay.conf
  33. src: overlay.conf.j2
  34. backup: yes
  35. - name: Manually modprobe overlay into the kernel
  36. command: modprobe overlay
  37. - name: Enable and start systemd-modules-load
  38. service:
  39. name: systemd-modules-load
  40. enabled: yes
  41. state: restarted
  42. - block:
  43. - name: Add http_proxy to /etc/atomic.conf
  44. lineinfile:
  45. dest: /etc/atomic.conf
  46. regexp: "^#?http_proxy[:=]{1}"
  47. line: "http_proxy: {{ openshift.common.http_proxy | default('') }}"
  48. when:
  49. - openshift.common.http_proxy is defined
  50. - openshift.common.http_proxy != ''
  51. - name: Add https_proxy to /etc/atomic.conf
  52. lineinfile:
  53. dest: /etc/atomic.conf
  54. regexp: "^#?https_proxy[:=]{1}"
  55. line: "https_proxy: {{ openshift.common.https_proxy | default('') }}"
  56. when:
  57. - openshift.common.https_proxy is defined
  58. - openshift.common.https_proxy != ''
  59. - name: Add no_proxy to /etc/atomic.conf
  60. lineinfile:
  61. dest: /etc/atomic.conf
  62. regexp: "^#?no_proxy[:=]{1}"
  63. line: "no_proxy: {{ openshift.common.no_proxy | default('') }}"
  64. when:
  65. - openshift.common.no_proxy is defined
  66. - openshift.common.no_proxy != ''
  67. - block:
  68. - name: Set to default prepend
  69. set_fact:
  70. l_crio_image_prepend: "docker.io/gscrivano"
  71. l_crio_image_name: "crio-o-fedora"
  72. - name: Use Centos based image when distribution is CentOS
  73. set_fact:
  74. l_crio_image_name: "cri-o-centos"
  75. when: ansible_distribution == "CentOS"
  76. - name: Use RHEL based image when distribution is Red Hat
  77. set_fact:
  78. l_crio_image_prepend: "registry.access.redhat.com"
  79. l_crio_image_name: "cri-o"
  80. when: ansible_distribution == "RedHat"
  81. # For https://github.com/openshift/openshift-ansible/pull/4049#discussion_r114478504
  82. - name: Use a testing registry if requested
  83. set_fact:
  84. l_crio_image_prepend: "{{ openshift_crio_systemcontainer_image_registry_override }}"
  85. when:
  86. - openshift_crio_systemcontainer_image_registry_override is defined
  87. - openshift_crio_systemcontainer_image_registry_override != ""
  88. - name: Set the full image name
  89. set_fact:
  90. l_crio_image: "{{ l_crio_image_prepend }}/{{ l_crio_image_name }}:latest"
  91. # NOTE: no_proxy added as a workaround until https://github.com/projectatomic/atomic/pull/999 is released
  92. - name: Pre-pull CRI-O System Container image
  93. command: "atomic pull --storage ostree {{ l_crio_image }}"
  94. changed_when: false
  95. environment:
  96. NO_PROXY: "{{ openshift.common.no_proxy | default('') }}"
  97. - name: Install CRI-O System Container
  98. oc_atomic_container:
  99. name: "cri-o"
  100. image: "{{ l_crio_image }}"
  101. state: latest
  102. - name: Create the CRI-O configuration
  103. template:
  104. dest: /etc/crio/crio.conf
  105. src: crio.conf.j2
  106. backup: yes
  107. - name: Ensure CNI configuration directory exists
  108. file:
  109. path: /etc/cni/net.d/
  110. state: directory
  111. - name: Configure the CNI network
  112. template:
  113. dest: /etc/cni/net.d/openshift-sdn.conf
  114. src: 80-openshift-sdn.conf.j2
  115. - name: Start the CRI-O service
  116. systemd:
  117. name: "cri-o"
  118. enabled: yes
  119. state: started
  120. daemon_reload: yes
  121. register: start_result
  122. - meta: flush_handlers