From 453cd2fd2b447cc6621f99a94a7404c6bc86da45 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 29 Jul 2021 12:46:52 +0200 Subject: [PATCH] Add default variables to docker-swarm role Variable `docker_stack_files_dir` can be used if other stack deployments need to copy over configuration files or other extra files. Defaults to `/stacks` but can be set to anything and other roles should take care to respect this and put their files relative to it. Variable `docker_swarm_public_network_name` can be used to set the name of the network to be created that faces outwards (ingress network) and to which all stacks will be connecting. --- roles/docker-swarm/defaults/main.yml | 5 +++++ roles/docker-swarm/tasks/main.yml | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 roles/docker-swarm/defaults/main.yml diff --git a/roles/docker-swarm/defaults/main.yml b/roles/docker-swarm/defaults/main.yml new file mode 100644 index 0000000..9399a91 --- /dev/null +++ b/roles/docker-swarm/defaults/main.yml @@ -0,0 +1,5 @@ +--- + +docker_stack_files_dir: /stacks +docker_swarm_public_network_name: public + diff --git a/roles/docker-swarm/tasks/main.yml b/roles/docker-swarm/tasks/main.yml index b15f36f..b21fb6e 100644 --- a/roles/docker-swarm/tasks/main.yml +++ b/roles/docker-swarm/tasks/main.yml @@ -19,7 +19,14 @@ - name: Ensure public network exists community.docker.docker_network: - name: public + name: "{{ docker_swarm_public_network_name }}" driver: overlay state: present become: true + +- name: Ensure stack files directory exists + ansible.builtin.file: + path: "{{ docker_stack_files_dir }}" + state: directory + mode: '0755' + become: true