From c160ba5193a86360263113d08172b1e093cf29b8 Mon Sep 17 00:00:00 2001 From: Nick Stokoe Date: Sun, 14 Feb 2021 17:46:45 +0000 Subject: [PATCH] snackpot.yml etc. - refine docker-compose config deploy The main job of this commit: - Be explicit about templates: expect the .j2 extension - Copy all other files, so that they can be binary - Don't deploy dotfiles or dotdirectories. This snuck in: - Remove `test` tag - Refine some descriptions --- snackpot.yml | 30 +++++++++++++++---- ...anion.env => letsencrypt-companion.env.j2} | 0 .../{nextcloud.env => nextcloud.env.j2} | 0 .../{postgres.env => postgres.env.j2} | 0 .../postgres/{Dockerfile => Dockerfile.j2} | 0 .../postgres/{init.sql => init.sql.j2} | 0 .../docker-compose/{web.env => web.env.j2} | 0 7 files changed, 24 insertions(+), 6 deletions(-) rename templates/docker-compose/{letsencrypt-companion.env => letsencrypt-companion.env.j2} (100%) rename templates/docker-compose/{nextcloud.env => nextcloud.env.j2} (100%) rename templates/docker-compose/{postgres.env => postgres.env.j2} (100%) rename templates/docker-compose/postgres/{Dockerfile => Dockerfile.j2} (100%) rename templates/docker-compose/postgres/{init.sql => init.sql.j2} (100%) rename templates/docker-compose/{web.env => web.env.j2} (100%) diff --git a/snackpot.yml b/snackpot.yml index 03e1a6f..84fc7be 100644 --- a/snackpot.yml +++ b/snackpot.yml @@ -76,12 +76,12 @@ path: "{{ docker_compose_base_dir }}/{{ item.path }}" state: directory with_filetree: templates/docker-compose - when: item.state == "directory" + when: item.state == "directory" and item.path.count("/.") == 0 tags: docker-config - - name: configure docker compose files + - name: deploy docker compose templates template: - dest: "{{ docker_compose_base_dir }}/{{ item.path }}" + dest: "{{ docker_compose_base_dir }}/{{ item.path | splitext | first }}" src: "docker-compose/{{ item.path }}" owner: root group: root @@ -89,15 +89,33 @@ backup: yes notify: restart docker compose services with_filetree: templates/docker-compose - when: item.state == "file" and not item.path.endswith("~") + when: item.state == "file" and item.path.endswith(".j2") + tags: docker-config + + - name: deploy docker compose files + copy: + dest: "{{ docker_compose_base_dir }}/{{ item.path }}" + src: "templates/docker-compose/{{ item.path }}" + owner: root + group: root + mode: 0660 + backup: yes + notify: restart docker compose services + with_filetree: templates/docker-compose + when: |- + item.state == "file" and not ( + item.path.endswith("~") or item.path.endswith(".j2") + or item.path.count("/.") > 0 + ) tags: docker-config - name: ensure directory exists file: path: "{{ docker_compose_base_dir }}/bin" state: directory + tags: docker-config - - name: install binaries + - name: install executables template: dest: "{{ docker_compose_base_dir }}/bin/{{ item.path }}" src: "bin/{{ item.path }}" @@ -106,6 +124,6 @@ mode: 0550 with_filetree: templates/bin when: item.state == "file" and not item.path.endswith("~") - tags: test + tags: docker-config # config nextcloud # hide pg password diff --git a/templates/docker-compose/letsencrypt-companion.env b/templates/docker-compose/letsencrypt-companion.env.j2 similarity index 100% rename from templates/docker-compose/letsencrypt-companion.env rename to templates/docker-compose/letsencrypt-companion.env.j2 diff --git a/templates/docker-compose/nextcloud.env b/templates/docker-compose/nextcloud.env.j2 similarity index 100% rename from templates/docker-compose/nextcloud.env rename to templates/docker-compose/nextcloud.env.j2 diff --git a/templates/docker-compose/postgres.env b/templates/docker-compose/postgres.env.j2 similarity index 100% rename from templates/docker-compose/postgres.env rename to templates/docker-compose/postgres.env.j2 diff --git a/templates/docker-compose/postgres/Dockerfile b/templates/docker-compose/postgres/Dockerfile.j2 similarity index 100% rename from templates/docker-compose/postgres/Dockerfile rename to templates/docker-compose/postgres/Dockerfile.j2 diff --git a/templates/docker-compose/postgres/init.sql b/templates/docker-compose/postgres/init.sql.j2 similarity index 100% rename from templates/docker-compose/postgres/init.sql rename to templates/docker-compose/postgres/init.sql.j2 diff --git a/templates/docker-compose/web.env b/templates/docker-compose/web.env.j2 similarity index 100% rename from templates/docker-compose/web.env rename to templates/docker-compose/web.env.j2