summaryrefslogtreecommitdiffstats
path: root/roles/openshift_registry/tasks/main.yml
blob: 2804e8f2e13da874b47f37a5ed7058ee1bc296f3 (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
---
- set_fact: _oreg_images="--images='{{ openshift.master.registry_url }}'"

- set_fact: _oreg_selector="--selector='{{ openshift.master.registry_selector }}'"

- name: Deploy OpenShift Registry
  command: >
    {{ openshift.common.admin_binary }} registry
    --create --service-account=registry {{ _oreg_selector }}
    --credentials={{ openshift_master_config_dir }}/openshift-registry.kubeconfig {{ _oreg_images }}
  register: _oreg_results
  changed_when: "'service exists' not in _oreg_results.stdout"

- name: Determine if nfs volume is already attached
  command: "{{ openshift.common.client_binary }} get -o template dc/docker-registry --template=\\{\\{.spec.template.spec.volumes\\}\\}"
  register: registry_volumes_output
  when: attach_registry_volume | bool

- set_fact:
    volume_already_attached: "{{ 'server:' + nfs_host in registry_volumes_output.stdout and 'path:' + registry_volume_path in registry_volumes_output.stdout }}"
  when: attach_registry_volume | bool

- name: Add nfs volume to dc/docker-registry
  command: >
    {{ openshift.common.client_binary }} volume dc/docker-registry
    --add --overwrite --name=registry-storage --mount-path=/registry
    --source='{"nfs": {"server": "{{ nfs_host }}", "path": "{{ registry_volume_path }}"}}'
  when: attach_registry_volume | bool and not volume_already_attached | bool