main.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ---
  2. - name: Create local temp dir for registry-console template
  3. command: mktemp -d /tmp/openshift-ansible-XXXXXXX
  4. register: mktemp
  5. # AUDIT:changed_when: not set here because this task actually
  6. # creates something
  7. - name: Copy the admin client config(s)
  8. command: >
  9. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  10. changed_when: False
  11. - name: Copy registry-console template to tmp dir
  12. copy:
  13. src: "registry-console.yaml"
  14. dest: "{{ mktemp.stdout }}/registry-console.yaml"
  15. - name: Create registry-console template
  16. command: >
  17. {{ openshift_client_binary }} create
  18. -f {{ mktemp.stdout }}/registry-console.yaml
  19. --config={{ mktemp.stdout }}/admin.kubeconfig
  20. -n openshift
  21. register: oht_import_templates
  22. failed_when: "'already exists' not in oht_import_templates.stderr and oht_import_templates.rc != 0"
  23. changed_when: "'created' in oht_import_templates.stdout"
  24. # When openshift_hosted_manage_registry=true the openshift_hosted
  25. # role will create the appropriate route for the docker-registry.
  26. # When openshift_hosted_manage_registry=false then this code will
  27. # not be run.
  28. - name: fetch the docker-registry route
  29. oc_route:
  30. kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
  31. name: docker-registry
  32. namespace: default
  33. state: list
  34. register: docker_registry_route
  35. - name: Create passthrough route for registry-console
  36. oc_route:
  37. kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
  38. name: registry-console
  39. namespace: default
  40. service_name: registry-console
  41. state: present
  42. tls_termination: passthrough
  43. register: registry_console_cockpit_kube
  44. - name: Deploy registry-console
  45. command: >
  46. {{ openshift_client_binary }} new-app --template=registry-console
  47. -p IMAGE_NAME="{{ openshift_cockpit_deployer_image }}"
  48. -p OPENSHIFT_OAUTH_PROVIDER_URL="{{ openshift.master.public_api_url }}"
  49. -p REGISTRY_HOST="{{ docker_registry_route.results[0].spec.host }}"
  50. -p COCKPIT_KUBE_URL="https://{{ registry_console_cockpit_kube.results.results[0].spec.host }}"
  51. --config={{ mktemp.stdout }}/admin.kubeconfig
  52. -n default
  53. register: deploy_registry_console
  54. changed_when: "'already exists' not in deploy_registry_console.stderr"
  55. failed_when:
  56. - "'already exists' not in deploy_registry_console.stderr"
  57. - "deploy_registry_console.rc != 0"
  58. - name: Delete temp directory
  59. file:
  60. name: "{{ mktemp.stdout }}"
  61. state: absent
  62. changed_when: False