main.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ---
  2. - include_tasks: udev_workaround.yml
  3. when: docker_udev_workaround | default(False) | bool
  4. - name: Add enterprise registry, if necessary
  5. set_fact:
  6. l2_docker_additional_registries: "{{ l2_docker_additional_registries + [openshift_docker_ent_reg] }}"
  7. when:
  8. - openshift.common.deployment_type == 'openshift-enterprise'
  9. - openshift_docker_ent_reg != ''
  10. - openshift_docker_ent_reg not in l2_docker_additional_registries
  11. - not openshift_use_crio_only | bool
  12. - name: Use Package Docker if Requested
  13. include_tasks: package_docker.yml
  14. when:
  15. - not openshift_docker_use_system_container
  16. - not openshift_use_crio_only
  17. - name: Ensure /var/lib/containers exists
  18. file:
  19. path: /var/lib/containers
  20. state: directory
  21. - name: Fix SELinux Permissions on /var/lib/containers
  22. command: "restorecon -R /var/lib/containers/"
  23. changed_when: false
  24. - name: Use System Container Docker if Requested
  25. include_tasks: systemcontainer_docker.yml
  26. when:
  27. - openshift_docker_use_system_container
  28. - not openshift_use_crio_only
  29. - name: Add CRI-O usage Requested
  30. include_tasks: systemcontainer_crio.yml
  31. when:
  32. - openshift_use_crio
  33. - openshift_docker_is_node_or_master | bool
  34. - name: stat the docker data dir
  35. stat:
  36. path: "{{ docker_default_storage_path }}"
  37. register: dockerstat
  38. - when:
  39. - openshift_use_crio
  40. - dockerstat.stat.islnk is defined and not (dockerstat.stat.islnk | bool)
  41. block:
  42. - name: stop the current running docker
  43. systemd:
  44. state: stopped
  45. name: "{{ openshift_docker_service_name }}"
  46. - name: copy "{{ docker_default_storage_path }}" to "{{ docker_alt_storage_path }}"
  47. command: "cp -r {{ docker_default_storage_path }} {{ docker_alt_storage_path }}"
  48. register: results
  49. failed_when:
  50. - results.rc != 0
  51. - name: "Set the selinux context on {{ docker_alt_storage_path }}"
  52. command: "semanage fcontext -a -e {{ docker_default_storage_path }} {{ docker_alt_storage_path }}"
  53. register: results
  54. failed_when:
  55. - results.rc == 1
  56. - "'already exists' not in results.stderr"
  57. - name: "restorecon the {{ docker_alt_storage_path }}"
  58. command: "restorecon -r {{ docker_alt_storage_path }}"
  59. - name: Remove the old docker location
  60. file:
  61. state: absent
  62. path: "{{ docker_default_storage_path }}"
  63. - name: Setup the link
  64. file:
  65. state: link
  66. src: "{{ docker_alt_storage_path }}"
  67. path: "{{ docker_default_storage_path }}"
  68. - name: start docker
  69. systemd:
  70. state: started
  71. name: "{{ openshift_docker_service_name }}"