registry.yml 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ---
  2. - block:
  3. - name: Retrieve list of openshift nodes matching registry selector
  4. oc_obj:
  5. state: list
  6. kind: node
  7. selector: "{{ openshift.hosted.registry.selector | default(omit) }}"
  8. register: registry_nodes
  9. - name: set_fact l_node_count to number of nodes matching registry selector
  10. set_fact:
  11. l_node_count: "{{ registry_nodes.results.results[0]['items'] | length }}"
  12. # Determine the default number of registry/router replicas to use if no count
  13. # has been specified.
  14. # If no registry nodes defined, the default should be 0.
  15. - name: set_fact l_default_replicas when l_node_count == 0
  16. set_fact:
  17. l_default_replicas: 0
  18. when: l_node_count | int == 0
  19. # If registry nodes are defined and the registry storage kind is
  20. # defined, default should be the number of registry nodes, otherwise
  21. # just 1:
  22. - name: set_fact l_default_replicas when l_node_count > 0
  23. set_fact:
  24. l_default_replicas: "{{ l_node_count if openshift.hosted.registry.storage.kind | default(none) is not none else 1 }}"
  25. when: l_node_count | int > 0
  26. when: openshift.hosted.registry.replicas | default(none) is none
  27. - name: set openshift_hosted facts
  28. set_fact:
  29. openshift_hosted_registry_replicas: "{{ openshift.hosted.registry.replicas | default(l_default_replicas) }}"
  30. openshift_hosted_registry_name: docker-registry
  31. openshift_hosted_registry_serviceaccount: registry
  32. openshift_hosted_registry_namespace: "{{ openshift.hosted.registry.namespace | default('default') }}"
  33. openshift_hosted_registry_selector: "{{ openshift.hosted.registry.selector }}"
  34. openshift_hosted_registry_images: "{{ openshift.hosted.registry.registryurl | default('openshift3/ose-${component}:${version}')}}"
  35. openshift_hosted_registry_volumes: []
  36. openshift_hosted_registry_env_vars: {}
  37. openshift_hosted_registry_edits:
  38. # These edits are being specified only to prevent 'changed' on rerun
  39. - key: spec.strategy.rollingParams
  40. value:
  41. intervalSeconds: 1
  42. maxSurge: "25%"
  43. maxUnavailable: "25%"
  44. timeoutSeconds: 600
  45. updatePeriodSeconds: 1
  46. action: put
  47. openshift_hosted_registry_force:
  48. - False
  49. - include: secure.yml
  50. static: no
  51. run_once: true
  52. when:
  53. - not (openshift.docker.hosted_registry_insecure | default(false) | bool)
  54. - include: storage/object_storage.yml
  55. static: no
  56. when:
  57. - openshift.hosted.registry.storage.kind | default(none) == 'object'
  58. - name: Set facts for persistent volume
  59. set_fact:
  60. pvc_volume_mounts:
  61. - name: registry-storage
  62. type: persistentVolumeClaim
  63. claim_name: "{{ openshift.hosted.registry.storage.volume.name }}-claim"
  64. openshift_hosted_registry_volumes: "{{ openshift_hosted_registry_volumes | union(pvc_volume_mounts) }}"
  65. when:
  66. - openshift.hosted.registry.storage.kind | default(none) in ['nfs', 'openstack']
  67. - name: Create OpenShift registry
  68. oc_adm_registry:
  69. name: "{{ openshift_hosted_registry_name }}"
  70. namespace: "{{ openshift_hosted_registry_namespace }}"
  71. selector: "{{ openshift_hosted_registry_selector }}"
  72. replicas: "{{ openshift_hosted_registry_replicas }}"
  73. service_account: "{{ openshift_hosted_registry_serviceaccount }}"
  74. images: "{{ openshift_hosted_registry_images }}"
  75. env_vars: "{{ openshift_hosted_registry_env_vars }}"
  76. volume_mounts: "{{ openshift_hosted_registry_volumes }}"
  77. edits: "{{ openshift_hosted_registry_edits }}"
  78. force: "{{ True|bool in openshift_hosted_registry_force }}"