Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for docker swarm mode #165

Merged
merged 5 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ install_python:
- python-setuptools
pip_packages:
- cryptography
- docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ docker_client_certificate_cache_directory:
docker_server_hostname: "{{ hostvars['xnat_cserv']['hostname'] }}"
docker_server_ip: "{{ hostvars['xnat_cserv']['ansible_ip'] }}"
docker_server_port: 2376
docker_swarm_enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ xnat_container_service_client_hostname: "{{ hostvars['xnat_web']['hostname'] }}"
xnat_container_service_validate_certs: "{{ ssl.validate_certs }}"

xnat_container_service_hostname: "{{ docker_server_hostname }}"
xnat_container_service_ip: "{{ docker_service_ip }}"
xnat_container_service_port: "{{ docker_server_port }}"
xnat_container_service_certificate_cache_directory:
"{{ docker_client_certificate_cache_directory }}"

xnat_container_service_path_translation_xnat_prefix: "{{ xnat_root_dir }}"
xnat_container_service_path_translation_docker_prefix: /storage/xnat/data/xnat

xnat_container_service_swarm_mode: "{{ docker_swarm_enabled }}"
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ install_python:
- python3-setuptools
pip_packages:
- cryptography
- docker
1 change: 1 addition & 0 deletions roles/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on CentOS 7 or Rocky Linux 8.
| `docker_rpm_gpg_key_url` | The url of the Docker repository GPG key. Defaults to `https://download.docker.com/linux/centos/gpg` |
| `docker_repo_baseurl` | URL to the directory containing the repodata. Defaults to `https://download.docker.com/linux/centos` |
| `docker_yum_package` | The name of the Docker package. Defaults to `docker` |
| `docker_swarm_enabled` | Initialise a [Docker Swarm](https://docs.docker.com/engine/swarm/). Defaults to `false`. |

If you would like to
[configure](https://docs.docker.com/engine/security/protect-access/#use-tls-https-to-protect-the-docker-daemon-socket)
Expand Down
3 changes: 3 additions & 0 deletions roles/docker/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ docker_client_certificate_directory:
"{{ docker_certificate_directory }}/client_certs"
docker_client_certificate_cache_directory:
"{{ lookup('env', 'HOME') }}/ansible_persistent_files/docker_certificates"

# Swarm mode
docker_swarm_enabled: false
5 changes: 5 additions & 0 deletions roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,8 @@
name: "{{ docker_service_name }}"
state: started
enabled: true

- name: Initialize Docker Swarm
community.docker.docker_swarm:
state: present
when: docker_swarm_enabled
5 changes: 4 additions & 1 deletion roles/xnat_container_service/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
cert-path:
"{{ xnat_container_service_certificate_directory if
xnat_container_service_use_ssl else '' }}"
swarm-mode: false
backend:
"{{ 'swarm' if xnat_container_service_swarm_mode else 'docker' }}"
swarm-mode: "{{ xnat_container_service_swarm_mode }}"
max-concurrent-finalizing-jobs: 1
path-translation-xnat-prefix:
"{{ xnat_container_service_path_translation_xnat_prefix }}"
path-translation-docker-prefix:
Expand Down