From aebedb0ed07f93666d957d592869e8d17c6190cc Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 6 Oct 2020 19:16:02 +0200 Subject: [PATCH] Fixes to the tasks that install as docker service --- defaults/main.yml | 1 + meta/main.yml | 1 + tasks/shinyproxy_docker_service.yml | 12 +++++++----- templates/shinyproxy-docker-compose.yml.j2 | 16 +++++++++++----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index cd9d3a8..93f7672 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -22,6 +22,7 @@ shinyproxy_default_apps: True shinyproxy_as_docker_src_dir: /srv/shinyproxy_service shinyproxy_as_docker_service_name: 'shinyproxy' shinyproxy_docker_network: 'shinyproxy' +shinyproxy_docker_swarm_replicas: 2 # Shinyproxy configuration # docker, docker-swarm, kubernetes shinyproxy_container_backend: 'docker' diff --git a/meta/main.yml b/meta/main.yml index 3e71b78..0f1d09f 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -31,4 +31,5 @@ dependencies: version: master name: openjdk state: latest + when: not shinyproxy_as_docker_service diff --git a/tasks/shinyproxy_docker_service.yml b/tasks/shinyproxy_docker_service.yml index 7b169e7..11c877a 100644 --- a/tasks/shinyproxy_docker_service.yml +++ b/tasks/shinyproxy_docker_service.yml @@ -10,11 +10,11 @@ - name: Install the shinyproxy docker file template: src=Dockerfile.j2 dest={{ shinyproxy_as_docker_src_dir }}/Dockerfile owner=root group=root mode=0444 - - name: Create the docker network used by shinyproxy - docker_network: - name: '{{ shinyproxy_docker_network }}' - driver: overlay - state: present + # - name: Create the docker network used by shinyproxy + # docker_network: + # name: '{{ shinyproxy_docker_network }}' + # driver: overlay + # state: present - name: Install the docker compose file template: src=shinyproxy-docker-compose.yml.j2 dest={{ shinyproxy_as_docker_src_dir }}/docker-compose.yml @@ -24,4 +24,6 @@ project_src: '{{ shinyproxy_as_docker_src_dir }}' build: yes + run_once: True + when: docker_swarm_manager_main_node is defined and docker_swarm_manager_main_node | bool tags: [ 'shinyproxy', 'shinyproxy_docker', 'docker' ] diff --git a/templates/shinyproxy-docker-compose.yml.j2 b/templates/shinyproxy-docker-compose.yml.j2 index 70760e1..674c1a9 100644 --- a/templates/shinyproxy-docker-compose.yml.j2 +++ b/templates/shinyproxy-docker-compose.yml.j2 @@ -1,17 +1,20 @@ -version: '3.8' +version: '3.6' services: shinyproxy: build: . volumes: - /var/run/docker.sock:/var/run/docker.sock - ports: - - '{{ shinyproxy_http_port }}':'{{ shinyproxy_http_port }}' + #ports: + # - '{{ shinyproxy_http_port }}':'{{ shinyproxy_http_port }}' + expose: + - "{{ shinyproxy_http_port }}" networks: - '{{ shinyproxy_docker_network }}' deploy: mode: replicated - replicas: 1 + replicas: {{ shinyproxy_docker_swarm_replicas }} + endpoint_mode: dnsrr placement: constraints: [node.role == manager] restart_policy: @@ -19,8 +22,11 @@ services: delay: 5s max_attempts: 3 window: 120s +{% if docker_log_to_journal %} + log_driver: 'journald' +{% endif %} networks: '{{ shinyproxy_docker_network }}': driver: overlay - attachable: true \ No newline at end of file + attachable: true