systemcontainer_crio.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 Red Hat or CentOS
  73. set_fact:
  74. l_crio_image_name: "cri-o-centos"
  75. when: ansible_distribution in ['RedHat', 'CentOS']
  76. # For https://github.com/openshift/openshift-ansible/pull/4049#discussion_r114478504
  77. - name: Use a testing registry if requested
  78. set_fact:
  79. l_crio_image_prepend: "{{ openshift_crio_systemcontainer_image_registry_override }}"
  80. when:
  81. - openshift_crio_systemcontainer_image_registry_override is defined
  82. - openshift_crio_systemcontainer_image_registry_override != ""
  83. - name: Set the full image name
  84. set_fact:
  85. l_crio_image: "{{ l_crio_image_prepend }}/{{ l_crio_image_name }}:latest"
  86. # NOTE: no_proxy added as a workaround until https://github.com/projectatomic/atomic/pull/999 is released
  87. - name: Pre-pull CRI-O System Container image
  88. command: "atomic pull --storage ostree {{ l_crio_image }}"
  89. changed_when: false
  90. environment:
  91. NO_PROXY: "{{ openshift.common.no_proxy | default('') }}"
  92. - name: Install CRI-O System Container
  93. oc_atomic_container:
  94. name: "cri-o"
  95. image: "{{ l_crio_image }}"
  96. state: latest
  97. - name: Create the CRI-O configuration
  98. template:
  99. dest: /etc/crio/crio.conf
  100. src: crio.conf.j2
  101. backup: yes
  102. - name: Ensure CNI configuration directory exists
  103. file:
  104. path: /etc/cni/net.d/
  105. state: directory
  106. - name: Configure the CNI network
  107. template:
  108. dest: /etc/cni/net.d/openshift-sdn.conf
  109. src: 80-openshift-sdn.conf.j2
  110. - name: Start the CRI-O service
  111. systemd:
  112. name: "cri-o"
  113. enabled: yes
  114. state: started
  115. daemon_reload: yes
  116. register: start_result
  117. - meta: flush_handlers