registry.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ---
  2. - name: setup firewall
  3. import_tasks: firewall.yml
  4. vars:
  5. l_openshift_hosted_firewall_enabled: "{{ r_openshift_hosted_registry_firewall_enabled }}"
  6. l_openshift_hosted_use_firewalld: "{{ r_openshift_hosted_registry_use_firewalld }}"
  7. l_openshift_hosted_fw_allow: "{{ r_openshift_hosted_registry_os_firewall_allow }}"
  8. l_openshift_hosted_fw_deny: "{{ r_openshift_hosted_registry_os_firewall_deny }}"
  9. - name: set openshift_hosted facts
  10. set_fact:
  11. # This determines the gluster_ips to use for the registry by looping over the glusterfs_registry group
  12. openshift_hosted_registry_storage_glusterfs_ips: "{%- set gluster_ips = [] %}{% if groups.glusterfs_registry is defined %}{% for node in groups.glusterfs_registry %}{%- set _ = gluster_ips.append(hostvars[node].glusterfs_ip | default(hostvars[node].openshift.common.ip)) %}{% endfor %}{{ gluster_ips }}{% elif groups.glusterfs is defined %}{% for node in groups.glusterfs %}{%- set _ = gluster_ips.append(hostvars[node].glusterfs_ip | default(hostvars[node].openshift.common.ip)) %}{% endfor %}{{ gluster_ips }}{% else %}{{ openshift_hosted_registry_storage_glusterfs_ips }}{% endif %}"
  13. - name: Update registry proxy settings for dc/docker-registry
  14. set_fact:
  15. openshift_hosted_registry_env_vars: "{{ {'HTTPS_PROXY': (openshift.common.https_proxy | default('')),
  16. 'HTTP_PROXY': (openshift.common.http_proxy | default('')),
  17. 'NO_PROXY': (openshift.common.no_proxy | default(''))}
  18. | combine(openshift_hosted_registry_env_vars) }}"
  19. when: (openshift.common.https_proxy | default(False)) or (openshift.common.http_proxy | default('')) != ''
  20. - name: Create the registry service account
  21. oc_serviceaccount:
  22. name: "{{ openshift_hosted_registry_serviceaccount }}"
  23. namespace: "{{ openshift_hosted_registry_namespace }}"
  24. - name: Grant the registry service account access to the appropriate scc
  25. oc_adm_policy_user:
  26. user: "system:serviceaccount:{{ openshift_hosted_registry_namespace }}:{{ openshift_hosted_registry_serviceaccount }}"
  27. namespace: "{{ openshift_hosted_registry_namespace }}"
  28. resource_kind: scc
  29. resource_name: hostnetwork
  30. - name: oc adm policy add-cluster-role-to-user system:registry system:serviceaccount:default:registry
  31. oc_adm_policy_user:
  32. user: "system:serviceaccount:{{ openshift_hosted_registry_namespace }}:{{ openshift_hosted_registry_serviceaccount }}"
  33. namespace: "{{ openshift_hosted_registry_namespace }}"
  34. resource_kind: cluster-role
  35. resource_name: system:registry
  36. - name: create the default registry service
  37. oc_service:
  38. namespace: "{{ openshift_hosted_registry_namespace }}"
  39. name: "{{ openshift_hosted_registry_name }}"
  40. ports:
  41. - name: 5000-tcp
  42. port: 5000
  43. protocol: TCP
  44. targetPort: 5000
  45. selector:
  46. docker-registry: default
  47. session_affinity: ClientIP
  48. service_type: ClusterIP
  49. clusterip: '{{ openshift_hosted_registry_clusterip | default(omit) }}'
  50. - include_tasks: secure.yml
  51. run_once: true
  52. when:
  53. - not (openshift_docker_hosted_registry_insecure | default(False)) | bool
  54. - include_tasks: storage/object_storage.yml
  55. when:
  56. - openshift_hosted_registry_storage_kind | default(none) == 'object'
  57. - name: Update openshift_hosted facts for persistent volumes
  58. set_fact:
  59. openshift_hosted_registry_volumes: "{{ openshift_hosted_registry_volumes | union(pvc_volume_mounts) }}"
  60. vars:
  61. pvc_volume_mounts:
  62. - name: registry-storage
  63. type: persistentVolumeClaim
  64. claim_name: "{{ openshift_hosted_registry_storage_volume_name }}-claim"
  65. when:
  66. - openshift_hosted_registry_storage_kind | default(none) in ['nfs', 'glusterfs', 'hostpath', 'openstack', 'vsphere']
  67. - include_tasks: storage/glusterfs_endpoints.yml
  68. when:
  69. - openshift_hosted_registry_storage_glusterfs_ips|length > 0
  70. - openshift_hosted_registry_storage_kind | default(none) in ['glusterfs']
  71. - name: Create OpenShift registry
  72. oc_adm_registry:
  73. name: "{{ openshift_hosted_registry_name }}"
  74. namespace: "{{ openshift_hosted_registry_namespace }}"
  75. selector: "{{ openshift_hosted_registry_selector }}"
  76. replicas: "{{ openshift_hosted_registry_replicas }}"
  77. service_account: "{{ openshift_hosted_registry_serviceaccount }}"
  78. images: "{{ openshift_hosted_registry_registryurl }}"
  79. env_vars: "{{ openshift_hosted_registry_env_vars }}"
  80. volume_mounts: "{{ openshift_hosted_registry_volumes }}"
  81. edits: "{{ openshift_hosted_registry_edits }}"
  82. force: "{{ True|bool in openshift_hosted_registry_force }}"