main.yaml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #
  2. # This role relies on gcloud invoked via templated bash in order to
  3. # provide a high performance deployment option. The next logical step
  4. # is to transition to a deployment manager template which is then instantiated.
  5. # TODO: use a formal set of role parameters consistent with openshift_aws
  6. #
  7. ---
  8. - name: Templatize DNS script
  9. template: src=dns.j2.sh dest=/tmp/openshift_gcp_provision_dns.sh mode=u+rx
  10. - name: Templatize provision script
  11. template: src=provision.j2.sh dest=/tmp/openshift_gcp_provision.sh mode=u+rx
  12. - name: Templatize de-provision script
  13. template: src=remove.j2.sh dest=/tmp/openshift_gcp_provision_remove.sh mode=u+rx
  14. when:
  15. - state | default('present') == 'absent'
  16. - name: Provision GCP DNS domain
  17. command: /tmp/openshift_gcp_provision_dns.sh
  18. args:
  19. chdir: "{{ playbook_dir }}/files"
  20. register: dns_provision
  21. when:
  22. - state | default('present') == 'present'
  23. - name: Ensure that DNS resolves to the hosted zone
  24. assert:
  25. that:
  26. - "lookup('dig', public_hosted_zone, 'qtype=NS', wantlist=True) | sort | join(',') == dns_provision.stdout"
  27. msg: "The DNS domain {{ public_hosted_zone }} defined in 'public_hosted_zone' must have NS records pointing to the Google nameservers: '{{ dns_provision.stdout }}' instead of '{{ lookup('dig', public_hosted_zone, 'qtype=NS') }}'."
  28. when:
  29. - state | default('present') == 'present'
  30. - name: Provision GCP resources
  31. command: /tmp/openshift_gcp_provision.sh
  32. args:
  33. chdir: "{{ playbook_dir }}/files"
  34. when:
  35. - state | default('present') == 'present'
  36. - name: De-provision GCP resources
  37. command: /tmp/openshift_gcp_provision_remove.sh
  38. when:
  39. - state | default('present') == 'absent'