commit 9f665a37d032cafcf39f63edb3b6d27e75dc9e80 Author: Antonio J. Delgado Date: Tue Oct 11 10:19:04 2022 +0300 Initial commit with previous code diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..e9a9cb0 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,31 @@ +--- +create_cache_file: true +auth_file: /var/lib/ntfy/auth.sqlite +base_url: notify.koti.site +listen_port: 4880 +attachment_cache_dir: /var/lib/ntfy/attachments +attachment_total_size_limit: "100G" +attachment_file_size_limit: "15M" +attachment_expiry_duration: "8h" + +# Full list in +# https://ntfy.sh/docs/config/ +admin_accounts: + - name: manager + password: "{{ vault_manager_password }}" +user_accounts: [] +access_rules: + - username: manager + topic: '*' # or something like mytopic* or my_topic + permission: read-write # or read-only, write-only, deny +ntfy_configuration: + behind-proxy: false + listen-http: ":4880" + cache-file: /var/lib/ntfy.sqlite + cache-duration: 24h + auth-file: "{{ auth_file }}" + auth-default-access: deny-all + attachment-cache-dir: "{{ attachment_cache_dir }}" + attachment-total-size-limit: "{{ attachment_total_size_limit }}" + attachment-file-size-limit: "{{ attachment_file_size_limit }}" + attachment-expiry-duration: "{{ attachment_expiry_duration }}" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..ebd48d8 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,3 @@ +--- +# - name: Refresh aliases +# shell: newaliases diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 0000000..97aa614 --- /dev/null +++ b/tasks/configure.yml @@ -0,0 +1,54 @@ +--- +- name: Configure ntfy + copy: + content: "{{ ntfy_configuration | to_nice_yaml(indent=4, width=250) }}" + dest: /etc/ntfy/server.yml + owner: root + group: root + mode: '0664' + backup: yes + +- name: Ensure cache file is accessible to ntfy + file: + path: "{{ cache_file }}" + owner: ntfy + group: ntfy + state: touch + mode: 0660 + when: cache_file is defined + +- name: Ensure auth file is accessible to ntfy + file: + path: "{{ auth_file }}" + owner: ntfy + group: ntfy + state: touch + mode: 0660 + when: auth_file is defined + +- name: Ensure attachments directory exists + file: + path: "{{ attachment_cache_dir }}" + owner: ntfy + group: ntfy + state: directory + mode: 0660 + when: attachment_cache_dir is defined + +- name: Ensure ntfy is enabled and started + systemd: + name: ntfy + state: started + enabled: true + +# - name: Configure administrators +# shell: "ntfy user add --role=admin {{ item.name }}" +# loop: "{{ admin_accounts }}" + +# - name: Configure users +# shell: "ntfy user add --role=user {{ item.name }}" +# loop: "{{ user_accounts }}" + +# - name: Grant permissions +# shell: "ntfy access {{ item.username }} {{ item.topic }} {{ item.permission }}" +# loop: "{{ access_rules }}" \ No newline at end of file diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..7875e0c --- /dev/null +++ b/tasks/install.yml @@ -0,0 +1,19 @@ +--- +- name: Ensure repository key is present + apt_key: + id: CF871F1E8399DAEF470832661D5B8EDFB2476E53 + url: https://archive.heckel.io/apt/pubkey.txt + keyring: /etc/apt/trusted.gpg.d/heckel.gpg + +- name: Install software required + apt: + name: apt-transport-https + +- name: Ensure repository is present + apt_repository: + repo: deb [arch=amd64] https://archive.heckel.io/apt debian main + filename: heckel + state: present +- name: Ensure ntfy is installed + apt: + name: ntfy \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..cbe813e --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,5 @@ +--- +- name: Ensure installation + include_tasks: install.yml +- name: Ensure configuration + include_tasks: configure.yml \ No newline at end of file diff --git a/templates/server.yml.j2 b/templates/server.yml.j2 new file mode 100644 index 0000000..7bd8a01 --- /dev/null +++ b/templates/server.yml.j2 @@ -0,0 +1,5 @@ +{% if ntfy_configuration is defined %} +{% for key, value in ntfy_configuration.items() %} + +{% endfor %} +{% endif %} \ No newline at end of file