summaryrefslogtreecommitdiffstats
path: root/roles/cockpit-ui/tasks/main.yml
blob: 1d42110b84a663a1185398a7c6ead0f1456289bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- block:

  # When openshift_hosted_manage_registry=true the openshift_hosted
  # role will create the appropriate route for the docker-registry.
  # When openshift_hosted_manage_registry=false then this code will
  # not be run.

  - name: Create passthrough route for registry-console
    oc_route:
      kubeconfig: "{{ openshift_master_config_dir }}/admin.kubeconfig"
      name: registry-console
      namespace: default
      service_name: registry-console
      state: present
      tls_termination: passthrough
    register: registry_console_cockpit_kube

  # XXX: Required for items still using command
  - name: Create temp directory for kubeconfig
    command: mktemp -d /tmp/openshift-ansible-XXXXXX
    register: mktemp
    changed_when: False

  - set_fact:
      openshift_hosted_kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"

  - name: Copy the admin client config(s)
    command: >
      cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ openshift_hosted_kubeconfig }}
    changed_when: False

  # TODO: Need to fix the origin and enterprise templates so that they both respect IMAGE_PREFIX
  - name: Deploy registry-console
    command: >
      {{ openshift.common.client_binary }} new-app --template=registry-console
      {% if openshift_cockpit_deployer_prefix is defined  %}-p IMAGE_PREFIX="{{ openshift_cockpit_deployer_prefix }}"{% endif %}
      {% if openshift_cockpit_deployer_version is defined  %}-p IMAGE_VERSION="{{ openshift_cockpit_deployer_version }}"{% endif %}
      -p OPENSHIFT_OAUTH_PROVIDER_URL="{{ openshift.master.public_api_url }}"
      -p REGISTRY_HOST="{{ docker_registry_route.results.results[0].spec.host }}"
      -p COCKPIT_KUBE_URL="https://{{ registry_console_cockpit_kube.results.results[0].spec.host }}"
      --config={{ openshift_hosted_kubeconfig }}
      -n default
    register: deploy_registry_console
    changed_when: "'already exists' not in deploy_registry_console.stderr"
    failed_when: "'already exists' not in deploy_registry_console.stderr and deploy_registry_console.rc != 0"

  - name: Delete temp directory
    file:
      name: "{{ mktemp.stdout }}"
      state: absent
    changed_when: False
    # XXX: End required for items still using command
  run_once: true