main.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. # tasks file for docker
  3. - name: Install docker
  4. action: "{{ ansible_pkg_mgr }} name=docker state=present"
  5. when: not openshift.common.is_atomic | bool
  6. - name: enable and start the docker service
  7. service:
  8. name: docker
  9. enabled: yes
  10. state: started
  11. register: start_result
  12. - set_fact:
  13. docker_service_status_changed: start_result | changed
  14. - include: udev_workaround.yml
  15. when: docker_udev_workaround | default(False) | bool
  16. - stat: path=/etc/sysconfig/docker
  17. register: docker_check
  18. - name: Set registry params
  19. lineinfile:
  20. dest: /etc/sysconfig/docker
  21. regexp: '^{{ item.reg_conf_var }}=.*$'
  22. line: "{{ item.reg_conf_var }}='{{ item.reg_fact_val | oo_prepend_strings_in_list(item.reg_flag ~ ' ') | join(' ') }}'"
  23. when: item.reg_fact_val is defined and docker_check.stat.isreg
  24. with_items:
  25. - reg_conf_var: ADD_REGISTRY
  26. reg_fact_val: "{{ docker_additional_registries }}"
  27. reg_flag: --add-registry
  28. - reg_conf_var: BLOCK_REGISTRY
  29. reg_fact_val: "{{ docker_blocked_registries }}"
  30. reg_flag: --block-registry
  31. - reg_conf_var: INSECURE_REGISTRY
  32. reg_fact_val: "{{ docker_insecure_registries }}"
  33. reg_flag: --insecure-registry
  34. notify:
  35. - restart docker
  36. - name: Set various docker options
  37. lineinfile:
  38. dest: /etc/sysconfig/docker
  39. regexp: '^OPTIONS=.*$'
  40. line: "OPTIONS='\
  41. {% if ansible_selinux and ansible_selinux.status == '''enabled''' %} --selinux-enabled{% endif %}\
  42. {% if docker_log_driver is defined %} --log-driver {{ docker_log_driver }}{% endif %}\
  43. {% if docker_log_options is defined %} {{ docker_log_options | oo_split() | oo_prepend_strings_in_list('--log-opt ') | join(' ')}}{% endif %}\
  44. {% if docker_options is defined %} {{ docker_options }}{% endif %}\
  45. {% if docker_disable_push_dockerhub is defined %} --confirm-def-push={{ docker_disable_push_dockerhub | bool }}{% endif %}'"
  46. when: docker_check.stat.isreg
  47. notify:
  48. - restart docker