diff --git a/roles/xnat_container_service/tasks/add_container_service_hub.yml b/roles/xnat_container_service/tasks/add_container_service_hub.yml new file mode 100644 index 00000000..af64a13a --- /dev/null +++ b/roles/xnat_container_service/tasks/add_container_service_hub.yml @@ -0,0 +1,29 @@ +--- +- name: Check if Image Host + ansible.builtin.uri: + url: + "{{ web_server.url }}/xapi/docker/hubs/{{ container_registry.name | + urlencode }}" + user: "{{ xnat_service_admin.username }}" + password: "{{ xnat_service_admin.password }}" + method: GET + validate_certs: "{{ ssl.validate_certs }}" + status_code: 200, 404 + register: hub_check + +- name: Configure Image Host + ansible.builtin.uri: + url: "{{ web_server.url }}/xapi/docker/hubs" + user: "{{ xnat_service_admin.username }}" + password: "{{ xnat_service_admin.password }}" + method: POST + body_format: json + body: + name: "{{ container_registry.name }}" + url: "{{ container_registry.url }}" + username: "{{ container_registry.username }}" + password: "{{ container_registry.password }}" + default: "{{ container_registry.default }}" + validate_certs: "{{ ssl.validate_certs }}" + status_code: 200, 201 + when: hub_check.status != 200 diff --git a/roles/xnat_container_service/tasks/main.yml b/roles/xnat_container_service/tasks/main.yml index 1800049e..3b82edb3 100644 --- a/roles/xnat_container_service/tasks/main.yml +++ b/roles/xnat_container_service/tasks/main.yml @@ -57,3 +57,10 @@ container-user: "" validate_certs: "{{ xnat_container_service_validate_certs }}" status_code: 200, 201 + +- name: Set up container service registries + ansible.builtin.include_tasks: add_container_service_hub.yml + vars: + container_registry: "{{ item }}" + loop: "{{ xnat_container_service_hubs | default([]) }}" + when: external_storage_drive is defined