secure.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ---
  2. - name: Set fact docker_registry_route_hostname
  3. set_fact:
  4. docker_registry_route_hostname: "{{ 'docker-registry-default.' ~ (openshift_master_default_subdomain | default('router.default.svc.cluster.local', true)) }}"
  5. - name: Create passthrough route for docker-registry
  6. oc_route:
  7. name: docker-registry
  8. namespace: "{{ openshift_hosted_registry_namespace }}"
  9. service_name: docker-registry
  10. tls_termination: passthrough
  11. host: "{{ docker_registry_route_hostname }}"
  12. - name: Retrieve registry service IP
  13. oc_service:
  14. namespace: "{{ openshift_hosted_registry_namespace }}"
  15. name: docker-registry
  16. state: list
  17. register: docker_registry_service_ip
  18. - name: Create registry certificates
  19. oc_adm_ca_server_cert:
  20. signer_cert: "{{ openshift_master_config_dir }}/ca.crt"
  21. signer_key: "{{ openshift_master_config_dir }}/ca.key"
  22. signer_serial: "{{ openshift_master_config_dir }}/ca.serial.txt"
  23. hostnames:
  24. - "{{ docker_registry_service_ip.results.clusterip }}"
  25. - docker-registry.default.svc.cluster.local
  26. - "{{ docker_registry_route_hostname }}"
  27. cert: "{{ openshift_master_config_dir }}/registry.crt"
  28. key: "{{ openshift_master_config_dir }}/registry.key"
  29. register: server_cert_out
  30. - name: Create the secret for the registry certificates
  31. oc_secret:
  32. name: registry-certificates
  33. namespace: "{{ openshift_hosted_registry_namespace }}"
  34. files:
  35. - name: registry.crt
  36. path: "{{ openshift_master_config_dir }}/registry.crt"
  37. - name: registry.key
  38. path: "{{ openshift_master_config_dir }}/registry.key"
  39. register: create_registry_certificates_secret_out
  40. - name: Add the secret to the registry's pod service accounts
  41. oc_serviceaccount_secret:
  42. service_account: "{{ item }}"
  43. secret: registry-certificates
  44. namespace: "{{ openshift_hosted_registry_namespace }}"
  45. with_items:
  46. - registry
  47. - default
  48. - name: Set facts for secure registry
  49. set_fact:
  50. registry_secure_volume_mounts:
  51. - name: registry-certificates
  52. path: /etc/secrets
  53. type: secret
  54. secret_name: registry-certificates
  55. registry_secure_env_vars:
  56. REGISTRY_HTTP_TLS_CERTIFICATE: /etc/secrets/registry.crt
  57. REGISTRY_HTTP_TLS_KEY: /etc/secrets/registry.key
  58. registry_secure_edits:
  59. - key: spec.template.spec.containers[0].livenessProbe.httpGet.scheme
  60. value: HTTPS
  61. action: put
  62. - key: spec.template.spec.containers[0].readinessProbe.httpGet.scheme
  63. value: HTTPS
  64. action: put
  65. - name: Update openshift_hosted facts with secure registry variables
  66. set_fact:
  67. openshift_hosted_registry_volumes: "{{ openshift_hosted_registry_volumes | union(registry_secure_volume_mounts) }}"
  68. openshift_hosted_registry_env_vars: "{{ openshift_hosted_registry_env_vars | combine(registry_secure_env_vars) }}"
  69. openshift_hosted_registry_edits: "{{ openshift_hosted_registry_edits | union(registry_secure_edits) }}"
  70. openshift_hosted_registry_force: "{{ openshift_hosted_registry_force | union([server_cert_out.changed]) | union([create_registry_certificates_secret_out.changed]) }}"