main.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ---
  2. - name: Set docker facts
  3. openshift_facts:
  4. role: "{{ item.role }}"
  5. local_facts: "{{ item.local_facts }}"
  6. with_items:
  7. - role: common
  8. local_facts:
  9. deployment_type: "{{ openshift_deployment_type }}"
  10. docker_additional_registries: "{{ docker_additional_registries }}"
  11. docker_insecure_registries: "{{ docker_insecure_registries }}"
  12. docker_blocked_registries: "{{ docker_blocked_registries }}"
  13. docker_options: "{{ openshift_docker_options | default('',True) }}"
  14. - role: node
  15. local_facts:
  16. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  17. docker_log_driver: "{{ lookup( 'oo_option' , 'docker_log_driver' ) | default('',True) }}"
  18. docker_log_options: "{{ lookup( 'oo_option' , 'docker_log_options' ) | default('',True) }}"
  19. - stat: path=/etc/sysconfig/docker
  20. register: docker_check
  21. - name: Set registry params
  22. lineinfile:
  23. dest: /etc/sysconfig/docker
  24. regexp: '^{{ item.reg_conf_var }}=.*$'
  25. line: "{{ item.reg_conf_var }}='{{ item.reg_fact_val | oo_prepend_strings_in_list(item.reg_flag ~ ' ') | join(' ') }}'"
  26. when: "'docker_additional_registries' in openshift.common and docker_check.stat.isreg"
  27. with_items:
  28. - reg_conf_var: ADD_REGISTRY
  29. reg_fact_val: "{{ openshift.common.docker_additional_registries }}"
  30. reg_flag: --add-registry
  31. - reg_conf_var: BLOCK_REGISTRY
  32. reg_fact_val: "{{ openshift.common.docker_blocked_registries }}"
  33. reg_flag: --block-registry
  34. - reg_conf_var: INSECURE_REGISTRY
  35. reg_fact_val: "{{ openshift.common.docker_insecure_registries }}"
  36. reg_flag: --insecure-registry
  37. notify:
  38. - restart openshift_docker
  39. # TODO: Enable secure registry when code available in origin
  40. # TODO: perhaps move this to openshift_docker?
  41. - name: Secure Registry and Logs Options
  42. lineinfile:
  43. dest: /etc/sysconfig/docker
  44. regexp: '^OPTIONS=.*$'
  45. line: "OPTIONS='--insecure-registry={{ openshift.node.portal_net }}\
  46. {% if ansible_selinux and ansible_selinux.status == '''enabled''' %} --selinux-enabled{% endif %}\
  47. {% if openshift.node.docker_log_driver is defined %} --log-driver {{ openshift.node.docker_log_driver }}{% endif %}\
  48. {% if openshift.node.docker_log_options is defined %} {{ openshift.node.docker_log_options | oo_split() | oo_prepend_strings_in_list('--log-opt ') | join(' ')}}{% endif %}\
  49. {% if openshift.common.docker_options is defined %} {{ openshift.common.docker_options }}{% endif %}'"
  50. when: docker_check.stat.isreg
  51. notify:
  52. - restart openshift_docker