diff --git a/playbooks/standupbot.yml b/playbooks/standupbot.yml new file mode 100644 index 0000000..3b383ab --- /dev/null +++ b/playbooks/standupbot.yml @@ -0,0 +1,5 @@ +--- +- name: Deploy standupbot + hosts: "{{ standupbot_hosts | default('standupbot') }}" + roles: + - standupbot diff --git a/roles/standupbot/README.md b/roles/standupbot/README.md new file mode 100644 index 0000000..81f7fcc --- /dev/null +++ b/roles/standupbot/README.md @@ -0,0 +1,17 @@ +# `famedly.matrix.standupbot` + +Deploys a containerized instance of [standupbot](https://github.com/beeper/standupbot). + +## Role Variables + + - `standupbot_homeserver`: Base URL of the matrix homeserver, for example `https://matrix.famedly.de`. + - `standupbot_username`: Full MXID of the bot user. + - `standupbot_password`: Password of the bot user. + +## License + +AGPL-3.0-only + +## Author Information + +- Jan Christian Grünhage diff --git a/roles/standupbot/defaults/main.yml b/roles/standupbot/defaults/main.yml new file mode 100644 index 0000000..0c99696 --- /dev/null +++ b/roles/standupbot/defaults/main.yml @@ -0,0 +1,2 @@ +--- +standupbot_base_path: /opt/standupbot diff --git a/roles/standupbot/handlers/main.yml b/roles/standupbot/handlers/main.yml new file mode 100644 index 0000000..a617073 --- /dev/null +++ b/roles/standupbot/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: Restart standupbot + community.docker.docker_container: + name: standupbot + state: started + restart: true + listen: restart-standupbot diff --git a/roles/standupbot/meta/main.yml b/roles/standupbot/meta/main.yml new file mode 100644 index 0000000..ba89ee5 --- /dev/null +++ b/roles/standupbot/meta/main.yml @@ -0,0 +1,18 @@ +--- +galaxy_info: + author: Jan Christian Grünhage + description: Deploy a containerized standupbot instance + company: Famedly GmbH + + license: AGPL-3.0-only + + min_ansible_version: "2.11" + + platforms: + - name: Debian + versions: + - bullseye + + galaxy_tags: [] + +dependencies: [] diff --git a/roles/standupbot/tasks/main.yml b/roles/standupbot/tasks/main.yml new file mode 100644 index 0000000..3a7291d --- /dev/null +++ b/roles/standupbot/tasks/main.yml @@ -0,0 +1,48 @@ +--- +- name: Ensure standupbot user is created + become: true + ansible.builtin.user: + name: standupbot + state: present + system: true + +- name: Ensure base directory for standupbot is created + become: true + ansible.builtin.file: + path: "{{ standupbot_base_path }}" + state: directory + owner: standupbot + group: standupbot + mode: 0755 + +- name: Ensure config file is up to date + become: true + ansible.builtin.copy: + content: "{{ standupbot_config | to_nice_json }}" + dest: "{{ standupbot_base_path }}/config.json" + owner: standupbot + group: standupbot + mode: 0600 + notify: restart-standupbot + +- name: Ensure password file is up to date + become: true + ansible.builtin.copy: + content: "{{ standupbot_password }}" + dest: "{{ standupbot_config.PasswordFile }}" + owner: standupbot + group: standupbot + mode: 0600 + notify: restart-standupbot + +- name: Ensure standupbot container is running + become: true + community.docker.docker_container: + image: ghcr.io/famedly/standupbot:latest + name: standupbot + restart_policy: unless-stopped + volumes: + - "{{ standupbot_base_path }}:{{ standupbot_base_path }}" + - "{{ standupbot_base_path }}/data:/root/.local/share/standupbot" + working_dir: "{{ standupbot_base_path }}" + command: "/usr/local/bin/standupbot" diff --git a/roles/standupbot/vars/main.yml b/roles/standupbot/vars/main.yml new file mode 100644 index 0000000..a83f789 --- /dev/null +++ b/roles/standupbot/vars/main.yml @@ -0,0 +1,5 @@ +--- +standupbot_config: + Homeserver: "{{ standupbot_homeserver }}" + Username: "{{ standupbot_username }}" + PasswordFile: "{{ standupbot_base_path }}/password_file"