From 56a7002f3304b71f0205c771fe8a9781190f80bd Mon Sep 17 00:00:00 2001 From: Joschka Seydell Date: Thu, 26 Nov 2020 13:02:48 -0800 Subject: [PATCH] Added install paths and new default values. --- README.md | 3 ++- defaults/main.yml | 2 ++ tasks/main.yml | 36 ++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index fd23f2a..4838446 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ Role Variables | Variable | Description | Default | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -| docker_user | The user who is going to manage/run the Docker Compose services | deploy | +| cryptpad_install_user | The user who is going to manage/run the Docker Compose services | {{ ansible_user }} | +| cryptpad_install_path | The location where the service should be deployed | /home/{{ cryptpad_install_user }} | | cryptpad_virtual_host | The virtual host that is e.g. used by Traefik, usually part of the public url | localhost | | cryptpad_safe_virtual_host | See above, and: this additonal domain is used together with `cryptpad_virtual_host` for additional security and must not be the same! More docs are in the `config.js` template | | | cryptpad_http_unsafe_origin_url | The URL of the public entrypoint URL, e.g. `https://pad.example.tld` | https:// + $cryptpad_virtual_host | diff --git a/defaults/main.yml b/defaults/main.yml index 9050ece..dcb67b3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,7 @@ --- # defaults file for jotbe.cryptpad-docker +cryptpad_install_user: '{{ ansible_user }}' # This user must be present on the host +cryptpad_install_path: '/home/{{ cryptpad_install_user }}' cryptpad_http_address: 127.0.0.1 cryptpad_http_unsafe_origin_url: https://{{ cryptpad_virtual_host }} cryptpad_http_safe_origin_url: https://{{ cryptpad_safe_virtual_host }} diff --git a/tasks/main.yml b/tasks/main.yml index d0d15d9..fa41e6d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,21 +2,21 @@ # tasks file for jotbe.cryptpad-docker - name: Ensure Docker Compose project directory exists file: - path: /home/{{ docker_user }}/cryptpad + path: "{{ cryptpad_install_path }}/cryptpad" state: directory - owner: '{{ docker_user }}' - group: '{{ docker_user }}' + owner: '{{ cryptpad_install_user }}' + group: '{{ cryptpad_install_user }}' - name: Provide docker-compose.yml template: src: templates/docker-compose.cryptpad.yml.j2 - dest: /home/{{ docker_user }}/cryptpad/docker-compose.yml - owner: "{{ docker_user }}" - group: "{{ docker_user }}" + dest: "{{ cryptpad_install_path }}/cryptpad/docker-compose.yml" + owner: "{{ cryptpad_install_user }}" + group: "{{ cryptpad_install_user }}" mode: '0644' - name: Output docker-compose.yml - shell: cat /home/{{ docker_user }}/cryptpad/docker-compose.yml + shell: cat {{ cryptpad_install_path }}/cryptpad/docker-compose.yml register: output - debug: @@ -24,9 +24,9 @@ - name: Provide env vars copy: - dest: /home/{{ docker_user }}/cryptpad/.env - owner: "{{ docker_user }}" - group: "{{ docker_user }}" + dest: "{{ cryptpad_install_path }}/cryptpad/.env" + owner: "{{ cryptpad_install_user }}" + group: "{{ cryptpad_install_user }}" mode: '0640' content: | VERSION=v3.24.0 @@ -36,28 +36,28 @@ - name: Ensure cryptpad config directory exists file: - path: /home/{{ docker_user }}/cryptpad/data/config + path: "{{ cryptpad_install_path }}/cryptpad/data/config" state: directory - owner: '{{ docker_user }}' - group: '{{ docker_user }}' + owner: '{{ cryptpad_install_user }}' + group: '{{ cryptpad_install_user }}' - name: Provide cryptpad config template: src: templates/config.js.j2 - dest: /home/{{ docker_user }}/cryptpad/data/config/config.js - owner: "{{ docker_user }}" - group: "{{ docker_user }}" + dest: "{{ cryptpad_install_path }}/cryptpad/data/config/config.js" + owner: "{{ cryptpad_install_user }}" + group: "{{ cryptpad_install_user }}" mode: '0644' - name: "docker-compose: Teardown existing cryptpad service" docker_compose: - project_src: "/home/{{ docker_user }}/cryptpad/" + project_src: "{{ cryptpad_install_path }}/cryptpad/" state: absent tags: ['never', 'teardown'] - name: "docker-compose: Start cryptpad service" docker_compose: - project_src: "/home/{{ docker_user }}/cryptpad/" + project_src: "{{ cryptpad_install_path }}/cryptpad/" pull: yes register: output tags: service_start