Skip to content

Commit

Permalink
✨ Add Twenty CRM
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 committed Apr 24, 2024
1 parent 7df72e8 commit 9a3ebf2
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Transmission](https://transmissionbt.com/) - BitTorrent client (with OpenVPN if you have a supported VPN provider)
* [Trilium](https://github.com/zadam/trilium) - Hierarchical note taking application with focus on building large personal knowledge bases
* [Tt-rss](https://tt-rss.org/) - free and open source web-based news feed (RSS/Atom) reader and aggregator
* [Twenty CMS](https://github.com/twentyhq/twenty) - The #1 Open-Source CRM
* [Ubooquity](http://vaemendis.net/ubooquity/) - Book and comic server
* [uTorrent](https://www.utorrent.com/) - The best torrent downloading app for beginners
* [Vaultwarden](https://github.com/dani-garcia/vaultwarden) - Self-Hosting port of password manager
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@
tags:
- ttrss

- role: twenty
tags:
- twenty

- role: ubooquity
tags:
- ubooquity
Expand Down
67 changes: 67 additions & 0 deletions roles/twenty/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
twenty_enabled: false
twenty_available_externally: false

# directories
twenty_data_directory: "{{ docker_home }}/twenty"

# network
twenty_port: "3014"
twenty_hostname: "twenty"
twenty_network_name: "twenty"

# specs
twenty_memory: 4g
twenty_db_memory: 1g

# docker
twenty_container_name: twenty
twenty_image_name: "twentycrm/twenty"
twenty_image_version: latest

twenty_db_container_name: twenty-db
twenty_db_image_name: "twentycrm/twenty-postgres"
twenty_db_image_version: latest

twenty_user_id: "1000"
twenty_group_id: "1000"

# twenty
twenty_pg_database_url: "postgres://{{ twenty_db_user }}:{{ twenty_db_password }}@{{ twenty_db_container_name }}:{{ twenty_db_port }}/default"
twenty_db_user: "twenty"
twenty_db_password: "twenty"
twenty_db_port: "5432"
twenty_server_url: "https://{{ twenty_hostname }}.{{ ansible_nas_domain }}"
twenty_front_base_url: "https://{{ twenty_hostname }}.{{ ansible_nas_domain }}"

twenty_enable_db_migrations: "true"

twenty_sign_in_prefilled: "true"
twenty_storage_type: "local"
twenty_storage_s3_region: "eu-west3"
twenty_storage_s3_name: "my-bucket"
twenty_storage_s3_endpoint: ""
# Use openssl rand -base64 32 for each secret
twenty_access_token_secret: "replace_me_with_a_random_string_access"
twenty_login_token_secret: "replace_me_with_a_random_string_access"
twenty_refresh_token_secret: "replace_me_with_a_random_string_access"
twenty_file_token_secret: "replace_me_with_a_random_string_access"


twenty_env:
PORT: "3000"
PG_DATABASE_URL: "{{ twenty_pg_database_url }}"
SERVER_URL: "{{ twenty_server_url }}"
FRONT_BASE_URL: "{{ twenty_front_base_url }}"

ENABLE_DB_MIGRATIONS: "{{ twenty_enable_db_migrations }}"

SIGN_IN_PREFILLED: "{{ twenty_sign_in_prefilled }}"
STORAGE_TYPE: "{{ twenty_storage_type }}"
# STORAGE_S3_REGION: "{{ twenty_storage_s3_region }}"
# STORAGE_S3_NAME: "{{ twenty_storage_s3_name }}"
# STORAGE_S3_ENDPOINT: "{{ twenty_storage_s3_endpoint }}"
ACCESS_TOKEN_SECRET: "{{ twenty_access_token_secret }}"
LOGIN_TOKEN_SECRET: "{{ twenty_login_token_secret }}"
REFRESH_TOKEN_SECRET: "{{ twenty_refresh_token_secret }}"
FILE_TOKEN_SECRET: "{{ twenty_file_token_secret }}"
11 changes: 11 additions & 0 deletions roles/twenty/docs/twenty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Twenty CMS

Homepage: [https://github.com/twentyhq/twenty](https://github.com/twentyhq/twenty)

The #1 Open-Source CRM. Modern, powerful, affordable platform to manage your customer relationships

## Usage

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

Twenty CMS web interface can be found at [http://ansible_nas_host_or_ip:8127](http://ansible_nas_host_or_ip:3014).
7 changes: 7 additions & 0 deletions roles/twenty/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
provisioner:
inventory:
group_vars:
all:
twenty_enabled: true
twenty_data_directory: /tmp/twenty
10 changes: 10 additions & 0 deletions roles/twenty/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:
twenty_enabled: false
26 changes: 26 additions & 0 deletions roles/twenty/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get twenty db container state
community.docker.docker_container:
name: "{{ twenty_db_container_name }}"
register: result_db

- name: Get twenty container state
community.docker.docker_container:
name: "{{ twenty_container_name }}"
register: result

- name: Check if twenty containers are running
ansible.builtin.assert:
that:
- result_db.container['State']['Status'] == "running"
- result_db.container['State']['Restarting'] == false
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
26 changes: 26 additions & 0 deletions roles/twenty/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- 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 twenty
community.docker.docker_container:
name: "{{ twenty_container_name }}"
state: absent
register: result

- name: Try and stop and remove twenty db
community.docker.docker_container:
name: "{{ twenty_db_container_name }}"
state: absent
register: result_db

- name: Check if twenty is stopped
ansible.builtin.assert:
that:
- not result.changed
- not result_db.changed
1 change: 1 addition & 0 deletions roles/twenty/requirements.yml
87 changes: 87 additions & 0 deletions roles/twenty/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
- name: Start Twenty
block:
- name: Create Twenty Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: 0777
with_items:
- "{{ twenty_data_directory }}"
- "{{ twenty_data_directory }}/data"

- name: Create Twenty DB Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "1001"
group: "1001"
with_items:
- "{{ twenty_data_directory }}/db-data"

- name: Create Twenty Network
community.docker.docker_network:
name: "{{ twenty_network_name }}"

- name: Create Twenty Db Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ twenty_db_container_name }}"
image: "{{ twenty_db_image_name }}:{{ twenty_db_image_version }}"
pull: true
networks:
- name: "{{ twenty_network_name }}"
network_mode: "{{ twenty_network_name }}"
volumes:
- "{{ twenty_data_directory }}/db-data:/bitnami/postgresql"
env:
POSTGRES_PASSWORD: "{{ twenty_db_password }}"
healthcheck:
test: pg_isready -U twenty -d default
interval: 5s
timeout: 5s
retries: 10
restart_policy: always
memory: "{{ twenty_db_memory }}"

- name: Create Twenty Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ twenty_container_name }}"
image: "{{ twenty_image_name }}:{{ twenty_image_version }}"
pull: true
networks:
- name: "{{ twenty_network_name }}"
network_mode: "{{ twenty_network_name }}"
volumes:
- "{{ twenty_data_directory }}/data:/app/.local-storage"
ports:
- "{{ twenty_port }}:3000"
env: "{{ twenty_env }}"
restart_policy: unless-stopped
memory: "{{ twenty_memory }}"
labels:
traefik.enable: "{{ twenty_available_externally | string }}"
traefik.http.routers.twenty.rule: "Host(`{{ twenty_hostname }}.{{ ansible_nas_domain }}`)"
# traefik.http.routers.twenty.tls.certresolver: "letsencrypt"
# traefik.http.routers.twenty.tls.domains[0].main: "{{ ansible_nas_domain }}"
# traefik.http.routers.twenty.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.twenty.loadbalancer.server.port: "3000"
healthcheck:
test: curl --fail http://localhost:3000/healthz
interval: 5s
timeout: 5s
retries: 10
when: twenty_enabled is true

- name: Stop Twenty
block:
- name: Stop Twenty
community.docker.docker_container:
name: "{{ twenty_container_name }}"
state: absent
- name: Stop Twenty Db
community.docker.docker_container:
name: "{{ twenty_db_container_name }}"
state: absent
when: twenty_enabled is false
14 changes: 14 additions & 0 deletions website/docs/applications/content-management/twenty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Twenty CMS"
description: "The #1 Open-Source CRM. Modern, powerful, affordable platform to manage your customer relationships"
---

Homepage: [https://github.com/twentyhq/twenty](https://github.com/twentyhq/twenty)

The #1 Open-Source CRM. Modern, powerful, affordable platform to manage your customer relationships

## Usage

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

Twenty CMS web interface can be found at [http://ansible_nas_host_or_ip:3014](http://ansible_nas_host_or_ip:3014).

0 comments on commit 9a3ebf2

Please sign in to comment.