s3.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. - name: Assert that S3 variables are provided for registry_config template
  3. assert:
  4. that:
  5. - openshift_hosted_registry_storage_s3_bucket | default(none) is not none
  6. - openshift_hosted_registry_storage_s3_region | default(none) is not none
  7. msg: |
  8. When using S3 storage, the following variables are required:
  9. openshift_hosted_registry_storage_s3_bucket
  10. openshift_hosted_registry_storage_s3_region
  11. - name: If cloudfront is being used, assert that we have all the required variables
  12. assert:
  13. that:
  14. - "openshift_hosted_registry_storage_s3_cloudfront_privatekeyfile | default(none) is not none"
  15. - "openshift_hosted_registry_storage_s3_cloudfront_keypairid | default(none) is not none"
  16. msg: |
  17. When openshift_hosted_registry_storage_s3_cloudfront_baseurl is provided
  18. openshift_hosted_registry_storage_s3_cloudfront_keypairid and
  19. openshift_hosted_registry_storage_s3_cloudfront_privatekeyfile are required
  20. when: openshift_hosted_registry_storage_s3_cloudfront_baseurl is defined
  21. # Inject the cloudfront private key as a secret when required
  22. - block:
  23. - name: Create registry secret for cloudfront
  24. oc_secret:
  25. state: present
  26. namespace: "{{ openshift_hosted_registry_namespace }}"
  27. name: docker-registry-s3-cloudfront
  28. contents:
  29. - path: cloudfront.pem
  30. data: "{{ lookup('file', openshift_hosted_registry_storage_s3_cloudfront_privatekeyfile) }}"
  31. - name: Append cloudfront secret registry volume to openshift_hosted_registry_volumes
  32. set_fact:
  33. openshift_hosted_registry_volumes: "{{ openshift_hosted_registry_volumes | union(s3_volume_mount) }}"
  34. vars:
  35. s3_volume_mount:
  36. - name: cloudfront-vol
  37. path: /etc/origin
  38. type: secret
  39. secret_name: docker-registry-s3-cloudfront
  40. when: openshift_hosted_registry_storage_s3_cloudfront_baseurl | default(none) is not none