main.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ---
  2. - block:
  3. # When openshift_hosted_manage_registry=true the openshift_hosted
  4. # role will create the appropriate route for the docker-registry.
  5. # When openshift_hosted_manage_registry=false then this code will
  6. # not be run.
  7. - name: fetch the docker-registry route
  8. oc_route:
  9. kubeconfig: "/etc/origin/master/admin.kubeconfig"
  10. name: docker-registry
  11. namespace: default
  12. state: list
  13. register: docker_registry_route
  14. - name: Create passthrough route for registry-console
  15. oc_route:
  16. kubeconfig: "/etc/origin/master/admin.kubeconfig"
  17. name: registry-console
  18. namespace: default
  19. service_name: registry-console
  20. state: present
  21. tls_termination: passthrough
  22. register: registry_console_cockpit_kube
  23. # XXX: Required for items still using command
  24. - name: Create temp directory for kubeconfig
  25. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  26. register: mktemp
  27. changed_when: False
  28. - set_fact:
  29. openshift_hosted_kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
  30. - name: Copy the admin client config(s)
  31. command: >
  32. cp /etc/origin/master/admin.kubeconfig {{ openshift_hosted_kubeconfig }}
  33. changed_when: False
  34. - name: Deploy registry-console
  35. command: >
  36. {{ openshift_client_binary }} new-app --template=registry-console
  37. {% if openshift_cockpit_deployer_prefix is defined %}-p IMAGE_PREFIX="{{ openshift_cockpit_deployer_prefix }}"{% endif %}
  38. {% if openshift_cockpit_deployer_basename is defined %}-p IMAGE_BASENAME="{{ openshift_cockpit_deployer_basename }}"{% endif %}
  39. {% if openshift_cockpit_deployer_version is defined %}-p IMAGE_VERSION="{{ openshift_cockpit_deployer_version }}"{% endif %}
  40. -p OPENSHIFT_OAUTH_PROVIDER_URL="{{ openshift.master.public_api_url }}"
  41. -p REGISTRY_HOST="{{ docker_registry_route.results[0].spec.host }}"
  42. -p COCKPIT_KUBE_URL="https://{{ registry_console_cockpit_kube.results.results[0].spec.host }}"
  43. --config={{ openshift_hosted_kubeconfig }}
  44. -n default
  45. register: deploy_registry_console
  46. changed_when: "'already exists' not in deploy_registry_console.stderr"
  47. failed_when:
  48. - "'already exists' not in deploy_registry_console.stderr"
  49. - "deploy_registry_console.rc != 0"
  50. - name: Delete temp directory
  51. file:
  52. name: "{{ mktemp.stdout }}"
  53. state: absent
  54. changed_when: False
  55. # XXX: End required for items still using command
  56. run_once: true