main.yml 2.3 KB

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