main.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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: Create passthrough route for registry-console
  8. oc_route:
  9. kubeconfig: "{{ openshift_master_config_dir }}/admin.kubeconfig"
  10. name: registry-console
  11. namespace: default
  12. service_name: registry-console
  13. state: present
  14. tls_termination: passthrough
  15. register: registry_console_cockpit_kube
  16. # XXX: Required for items still using command
  17. - name: Create temp directory for kubeconfig
  18. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  19. register: mktemp
  20. changed_when: False
  21. - set_fact:
  22. openshift_hosted_kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
  23. - name: Copy the admin client config(s)
  24. command: >
  25. cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ openshift_hosted_kubeconfig }}
  26. changed_when: False
  27. # TODO: Need to fix the origin and enterprise templates so that they both respect IMAGE_PREFIX
  28. - name: Deploy registry-console
  29. command: >
  30. {{ openshift.common.client_binary }} new-app --template=registry-console
  31. {% if openshift_cockpit_deployer_prefix is defined %}-p IMAGE_PREFIX="{{ openshift_cockpit_deployer_prefix }}"{% endif %}
  32. {% if openshift_cockpit_deployer_version is defined %}-p IMAGE_VERSION="{{ openshift_cockpit_deployer_version }}"{% endif %}
  33. -p OPENSHIFT_OAUTH_PROVIDER_URL="{{ openshift.master.public_api_url }}"
  34. -p REGISTRY_HOST="{{ docker_registry_route.results.results[0].spec.host }}"
  35. -p COCKPIT_KUBE_URL="https://{{ registry_console_cockpit_kube.results.results[0].spec.host }}"
  36. --config={{ openshift_hosted_kubeconfig }}
  37. -n default
  38. register: deploy_registry_console
  39. changed_when: "'already exists' not in deploy_registry_console.stderr"
  40. failed_when: "'already exists' not in deploy_registry_console.stderr and deploy_registry_console.rc != 0"
  41. - name: Delete temp directory
  42. file:
  43. name: "{{ mktemp.stdout }}"
  44. state: absent
  45. changed_when: False
  46. # XXX: End required for items still using command
  47. run_once: true