systemcontainer_docker.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ---
  2. # If docker_options are provided we should fail. We should not install docker and ignore
  3. # the users configuration. NOTE: docker_options == inventory:openshift_docker_options
  4. - name: Fail quickly if openshift_docker_options are set
  5. assert:
  6. that:
  7. - "{% if not openshift_docker_options %}1{% else %}0{% endif %}"
  8. msg: |
  9. Docker via System Container does not allow for the use of the openshift_docker_options
  10. variable. If you want to use openshift_docker_options you will need to use the
  11. traditional docker package install. Otherwise, comment out openshift_docker_options
  12. in your inventory file.
  13. - include_tasks: common/pre.yml
  14. - include_tasks: common/syscontainer_packages.yml
  15. # Make sure Docker is installed so we are able to use the client
  16. - name: Install Docker so we can use the client
  17. package: name=docker{{ '-' + docker_version if docker_version is defined else '' }} state=present
  18. when: not openshift_is_atomic | bool
  19. register: result
  20. until: result is succeeded
  21. # Make sure docker is disabled. Errors are ignored.
  22. - name: Disable Docker
  23. systemd:
  24. name: docker
  25. enabled: no
  26. state: stopped
  27. daemon_reload: yes
  28. ignore_errors: True
  29. register: r_docker_systemcontainer_docker_stop_result
  30. until: not (r_docker_systemcontainer_docker_stop_result is failed)
  31. retries: 3
  32. delay: 30
  33. - name: Ensure proxies are in the atomic.conf
  34. include_tasks: common/atomic_proxy.yml
  35. # Be nice and let the user see the variable result
  36. - debug:
  37. var: l_docker_image
  38. # Do the authentication before pulling the container engine system container
  39. # as the pull might be from an authenticated registry.
  40. - include_tasks: registry_auth.yml
  41. vars:
  42. openshift_docker_alternative_creds: True
  43. # NOTE: no_proxy added as a workaround until https://github.com/projectatomic/atomic/pull/999 is released
  44. - name: Pre-pull Container Engine System Container image
  45. command: "atomic pull --storage ostree {{ l_docker_image }}"
  46. changed_when: false
  47. environment:
  48. NO_PROXY: "{{ docker_no_proxy }}"
  49. - name: Ensure container-engine.service.d directory exists
  50. file:
  51. path: "{{ container_engine_systemd_dir }}"
  52. state: directory
  53. - name: Ensure /etc/docker directory exists
  54. file:
  55. path: "{{ docker_conf_dir }}"
  56. state: directory
  57. - name: Install Container Engine System Container
  58. oc_atomic_container:
  59. name: "{{ openshift_docker_service_name }}"
  60. image: "{{ l_docker_image }}"
  61. state: latest
  62. - name: Configure Container Engine Service File
  63. template:
  64. dest: "{{ container_engine_systemd_dir }}/custom.conf"
  65. src: systemcontainercustom.conf.j2
  66. # Configure container-engine using the container-daemon.json file
  67. # NOTE: daemon.json and container-daemon.json have been seperated to avoid
  68. # collision.
  69. - name: Configure Container Engine
  70. template:
  71. dest: "{{ docker_conf_dir }}/container-daemon.json"
  72. src: daemon.json
  73. # Enable and start the container-engine service
  74. - name: Start the Container Engine service
  75. systemd:
  76. name: "{{ openshift_docker_service_name }}"
  77. enabled: yes
  78. state: started
  79. daemon_reload: yes
  80. register: r_docker_systemcontainer_docker_start_result
  81. until: not (r_docker_systemcontainer_docker_start_result is failed)
  82. retries: 3
  83. delay: 30
  84. - set_fact:
  85. docker_service_status_changed: "{{ r_docker_systemcontainer_docker_start_result is changed }}"
  86. # Since docker is running as a system container, docker login will fail to create
  87. # credentials. Use alternate method if requiring authenticated registries.
  88. - include_tasks: common/post.yml
  89. vars:
  90. openshift_docker_alternative_creds: True