Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Chatwoot #137

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Calibre-web](https://github.com/janeczku/calibre-web) - Provides a clean interface for browsing, reading and downloading eBooks using an existing Calibre database.
* [Changedetection.io](https://github.com/dgtlmoon/changedetection.io) - Free open source website change detection, monitor and notification service
* [Chatpad](https://chatpad.ai/) - Not just another ChatGPT user-interface!
* [Chatwoot](https://github.com/chatwoot/chatwoot) - Open-source live-chat, email support, omni-channel desk
* [Claper](https://claper.co/) - The ultimate tool to interact with your audience
* [Code Server](https://code.visualstudio.com/) - Powerful IDE from Microsoft accessible through the browser
* [CommaFeed](https://www.commafeed.com/) - Google Reader inspired self-hosted RSS reader
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
tags:
- chatpad

- role: chatwoot
tags:
- chatwoot

- role: claper
tags:
- claper
Expand Down
558 changes: 558 additions & 0 deletions roles/chatwoot/defaults/main.yml

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions roles/chatwoot/docs/chatwoot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Chatwoot

Homepage: [https://github.com/chatwoot/chatwoot](https://github.com/chatwoot/chatwoot)

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc.

## Usage

Set `chatwoot_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

chatwoot web interface can be found at [http://ansible_nas_host_or_ip:3022](http://ansible_nas_host_or_ip:3022).
6 changes: 6 additions & 0 deletions roles/chatwoot/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
chatwoot_enabled: true
10 changes: 10 additions & 0 deletions roles/chatwoot/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
chatwoot_enabled: false
40 changes: 40 additions & 0 deletions roles/chatwoot/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get chatwoot postgres container state
community.docker.docker_container:
name: "{{ chatwoot_postgres_container_name }}"
register: result_postgres

- name: Get chatwoot redis container state
community.docker.docker_container:
name: "{{ chatwoot_redis_container_name }}"
register: result_redis

- name: Get chatwoot rails container state
community.docker.docker_container:
name: "{{ chatwoot_rails_container_name }}"
register: result_rails

- name: Get chatwoot sidekick container state
community.docker.docker_container:
name: "{{ chatwoot_sidekick_container_name }}"
register: result_sidekick

- name: Check if chatwoot containers are running
ansible.builtin.assert:
that:
- result_mongo.container['State']['Status'] == "running"
- result_mongo.container['State']['Restarting'] == false
- result_redis.container['State']['Status'] == "running"
- result_redis.container['State']['Restarting'] == false
- result_rails.container['State']['Status'] == "running"
- result_rails.container['State']['Restarting'] == false
- result_sidekick.container['State']['Status'] == "running"
- result_sidekick.container['State']['Restarting'] == false
40 changes: 40 additions & 0 deletions roles/chatwoot/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove chatwoot postgres
community.docker.docker_container:
name: "{{ chatwoot_postgres_container_name }}"
state: absent
register: result_postgres

- name: Try and stop and remove chatwoot redis
community.docker.docker_container:
name: "{{ chatwoot_redis_container_name }}"
state: absent
register: result_redis

- name: Try and stop and remove chatwoot sidekick
community.docker.docker_container:
name: "{{ chatwoot_sidekick_container_name }}"
state: absent
register: result_sidekick

- name: Try and stop and remove chatwoot rails
community.docker.docker_container:
name: "{{ chatwoot_rails_container_name }}"
state: absent
register: result_rails

- name: Check if chatwoot is stopped
ansible.builtin.assert:
that:
- not result_postgres.changed
- not result_redis.changed
- not result_sidekick.changed
- not result_rails.changed
1 change: 1 addition & 0 deletions roles/chatwoot/requirements.yml
123 changes: 123 additions & 0 deletions roles/chatwoot/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
- name: Start Chatwoot
block:
- name: Create Chatwoot Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ chatwoot_data_directory }}"

- name: Create Chatwoot network
community.docker.docker_network:
name: "{{ chatwoot_network_name }}"

- name: Create Chatwoot Postgres Docker Container
community.docker.docker_container:
name: "{{ chatwoot_postgres_container_name }}"
image: "{{ chatwoot_postgres_image_name }}:{{ chatwoot_postgres_image_version }}"
pull: true
volumes:
- "{{ chatwoot_data_directory }}/postgres:/var/lib/postgresql/data:rw"
networks:
- name: "{{ chatwoot_network_name }}"
network_mode: "{{ chatwoot_network_name }}"
container_default_behavior: no_defaults
env:
POSTGRES_DB: "{{ chatwoot_postgres_database }}"
POSTGRES_USER: "{{ chatwoot_postgres_username }}"
POSTGRES_PASSWORD: "{{ chatwoot_postgres_password }}"
labels:
traefik.enable: "false"
restart_policy: always
memory: "{{ chatwoot_postgres_memory }}"

- name: Create Chatwoot Redis Docker Container
community.docker.docker_container:
name: "{{ chatwoot_redis_container_name }}"
image: "{{ chatwoot_redis_image_name }}:{{ chatwoot_redis_image_version }}"
pull: true
volumes:
- "{{ chatwoot_data_directory }}/redis:/data:rw"
networks:
- name: "{{ chatwoot_network_name }}"
network_mode: "{{ chatwoot_network_name }}"
container_default_behavior: no_defaults
command: ["sh", "-c", "redis-server --requirepass \"{{ chatwoot_redis_password }}\""]
labels:
traefik.enable: "false"
restart_policy: always
memory: "{{ chatwoot_redis_memory }}"

- name: Create Chatwoot Rails Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ chatwoot_rails_container_name }}"
image: "{{ chatwoot_rails_image_name }}:{{ chatwoot_rails_image_version }}"
pull: true
volumes:
- "{{ chatwoot_data_directory }}/storage:/app/storage:rw"
networks:
- name: "{{ chatwoot_network_name }}"
network_mode: "{{ chatwoot_network_name }}"
ports:
- "{{ chatwoot_port }}:3000"
env: "{{ chatwoot_env }}"
restart_policy: unless-stopped
memory: "{{ chatwoot_rails_memory }}"
entrypoint: docker/entrypoints/rails.sh
command: ['bundle', 'exec', 'rails', 's', '-p', '3000', '-b', '0.0.0.0']
labels:
traefik.enable: "{{ chatwoot_available_externally | string }}"
traefik.http.routers.chatwoot.rule: "Host(`{{ chatwoot_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.chatwoot.tls.certresolver: "letsencrypt"
traefik.http.routers.chatwoot.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.chatwoot.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.chatwoot.loadbalancer.server.port: "3000"

- name: Create Chatwoot Sidekick Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ chatwoot_sidekick_container_name }}"
image: "{{ chatwoot_sidekick_image_name }}:{{ chatwoot_sidekick_image_version }}"
pull: true
volumes:
- "{{ chatwoot_data_directory }}/storage:/app/storage:rw"
networks:
- name: "{{ chatwoot_network_name }}"
network_mode: "{{ chatwoot_network_name }}"
env: "{{ chatwoot_env }}"
restart_policy: unless-stopped
memory: "{{ chatwoot_sidekick_memory }}"
command: ['bundle', 'exec', 'sidekiq', '-C', 'config/sidekiq.yml']
labels:
traefik.enable: "false"

- name: Prepare the database
ansible.builtin.command: /usr/bin/docker exec {{ chatwoot_rails_container_name }} bundle exec rails db:chatwoot_prepare
changed_when: false
tags: molecule-idempotence-notest
when: chatwoot_enabled is true

- name: Stop Chatwoot
block:
- name: Stop Chatwoot Postgres
community.docker.docker_container:
name: "{{ chatwoot_postgres_container_name }}"
state: absent

- name: Stop Chatwoot Redis
community.docker.docker_container:
name: "{{ chatwoot_redis_container_name }}"
state: absent

- name: Stop Chatwoot Rails
community.docker.docker_container:
name: "{{ chatwoot_rails_container_name }}"
state: absent

- name: Stop Chatwoot Sidekick
community.docker.docker_container:
name: "{{ chatwoot_sidekick_container_name }}"
state: absent
when: chatwoot_enabled is false
15 changes: 15 additions & 0 deletions website/docs/applications/other/chatwoot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "Chatwoot"
description: "About
Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬"
---

Homepage: [https://github.com/chatwoot/chatwoot](https://github.com/chatwoot/chatwoot)

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc.

## Usage

Set `chatwoot_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

chatwoot web interface can be found at [http://ansible_nas_host_or_ip:3022](http://ansible_nas_host_or_ip:3022).