From 0fe33fc9e3d2380a0b4b5926ce2108306aa325bd Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 10 Jan 2025 17:42:44 +0100 Subject: [PATCH] Added friendica draft and solved mariadb bug --- group_vars/all | 1 + playbook.servers.yml | 9 +++++ roles/docker-friendica/README.md | 4 ++ roles/docker-friendica/tasks/main.yml | 10 +++++ .../templates/docker-compose.yml.j2 | 37 +++++++++++++++++++ roles/docker-friendica/vars/main.yml | 3 ++ roles/docker-mariadb/tasks/main.yml | 12 +++--- 7 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 roles/docker-friendica/README.md create mode 100644 roles/docker-friendica/tasks/main.yml create mode 100644 roles/docker-friendica/templates/docker-compose.yml.j2 create mode 100644 roles/docker-friendica/vars/main.yml diff --git a/group_vars/all b/group_vars/all index 3f8f5352..04547305 100644 --- a/group_vars/all +++ b/group_vars/all @@ -127,6 +127,7 @@ domain_baserow: "baserow.{{top_domain}}" domain_bigbluebutton: "meet.{{top_domain}}" domain_discourse: "forum.{{top_domain}}" domain_elk: "elk.{{top_domain}}" +domain_friendica: "friendica.{{top_domain}}" domain_funkwhale: "music.{{top_domain}}" domain_gitea: "git.{{top_domain}}" domain_gitlab: "gitlab.{{top_domain}}" diff --git a/playbook.servers.yml b/playbook.servers.yml index a7587fa7..fbbcac2f 100644 --- a/playbook.servers.yml +++ b/playbook.servers.yml @@ -268,6 +268,15 @@ domain: "{{domain_taiga}}" http_port: 8027 +- name: setup friendica hosts + hosts: friendica + become: true + roles: + - role: docker-friendica + vars: + domain: "{{domain_friendica}}" + http_port: 8028 + # Native Webserver Roles - name: setup nginx-homepages hosts: homepage diff --git a/roles/docker-friendica/README.md b/roles/docker-friendica/README.md new file mode 100644 index 00000000..256c4a72 --- /dev/null +++ b/roles/docker-friendica/README.md @@ -0,0 +1,4 @@ +# role friendica + +## More information +- https://hub.docker.com/_/friendica \ No newline at end of file diff --git a/roles/docker-friendica/tasks/main.yml b/roles/docker-friendica/tasks/main.yml new file mode 100644 index 00000000..452e6d50 --- /dev/null +++ b/roles/docker-friendica/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: "include docker/compose/database.yml" + include_tasks: docker/compose/database.yml + +- name: "include tasks nginx-docker-proxy-domain.yml" + include_tasks: nginx-docker-proxy-domain.yml + +- name: add docker-compose.yml + template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml + notify: docker compose project setup diff --git a/roles/docker-friendica/templates/docker-compose.yml.j2 b/roles/docker-friendica/templates/docker-compose.yml.j2 new file mode 100644 index 00000000..6c022d6a --- /dev/null +++ b/roles/docker-friendica/templates/docker-compose.yml.j2 @@ -0,0 +1,37 @@ +services: + +{% include 'templates/docker/services/' + database_type + '.yml.j2' %} + + application: + image: friendica + restart: always + volumes: + - data:/var/www/html + ports: + - "127.0.0.1:{{http_port}}:80" + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:80"] + interval: 1m + timeout: 10s + retries: 3 + environment: + - FRIENDICA_URL="https://{{domain}}" + - FRIENDICA_ADMIN_MAIL={{administrator_email}} + - MYSQL_HOST={{database_host}}:3306 + - MYSQL_DATABASE={{database_name}} + - MYSQL_USER={{database_username}} + - MYSQL_PASSWORD={{database_password}} + - SMTP={{system_email_host}} + - SMTP_DOMAIN={{ system_email_host }} + - SMTP_PORT={{system_email_smtp_port}} + - SMTP_AUTH_USER={{system_email_username}} + - SMTP_AUTH_PASS={{system_email_password}} + - SMTP_STARTTLS={{system_email_start_tls}} + - SMTP_FROM={{system_email_username}} +{% include 'templates/docker/container/networks.yml.j2' %} +{% include 'templates/docker/container/depends-on-just-database.yml.j2' %} + +{% include 'templates/docker/compose/volumes.yml.j2' %} + data: + +{% include 'templates/docker/compose/networks.yml.j2' %} \ No newline at end of file diff --git a/roles/docker-friendica/vars/main.yml b/roles/docker-friendica/vars/main.yml new file mode 100644 index 00000000..0239a880 --- /dev/null +++ b/roles/docker-friendica/vars/main.yml @@ -0,0 +1,3 @@ +docker_compose_project_name: "friendica" +database_password: "{{friendica_database_password}}" +database_type: "mariadb" \ No newline at end of file diff --git a/roles/docker-mariadb/tasks/main.yml b/roles/docker-mariadb/tasks/main.yml index e3876a0e..d5de0e07 100644 --- a/roles/docker-mariadb/tasks/main.yml +++ b/roles/docker-mariadb/tasks/main.yml @@ -48,12 +48,6 @@ login_host: 127.0.0.1 login_port: 3306 -- name: Grant database privileges - ansible.builtin.shell: - cmd: "docker exec central-mariadb mariadb -u root -p{{ central_mariadb_root_password }} -e \"GRANT ALL PRIVILEGES ON {{database_name}}.* TO '{{database_username}}'@'%';\"" - args: - executable: /bin/bash - - name: "Create database user: {{ database_username }}" mysql_user: name: "{{database_username}}" @@ -66,6 +60,12 @@ login_host: 127.0.0.1 login_port: 3306 +- name: Grant database privileges + ansible.builtin.shell: + cmd: "docker exec central-mariadb mariadb -u root -p{{ central_mariadb_root_password }} -e \"GRANT ALL PRIVILEGES ON {{database_name}}.* TO '{{database_username}}'@'%';\"" + args: + executable: /bin/bash + - name: run the docker_mariadb tasks once set_fact: run_once_docker_mariadb: true