mother-of-all-self-hosting/mash-playbook

gitea_container_additional_networks_custom variable is not used/working

Closed this issue · 2 comments

Hi,
I'm trying to use the mash-exim-relay in Gitea. After realizing that they are not in the same network, I tried to add Gitea to the mash-exim-relay-network with the gitea_container_additional_networks_custom variable. => this is not working.

Somehow the custom variable is not used in the run of the playbook. I tested it by adding

- name: Debug custom network configuration
  debug:
    msg: "Error: custom: {{ gitea_container_additional_networks_custom }}  all: {{ gitea_container_additional_networks }}"

at the end of roles/gitea/tasks/install.yml.

The custom networks is not added to gitea_container_additional_networks, like it is configured here (ansible-role-gitea/defaults/main.yml):

# A list of additional container networks that the container would be connected to.
# The playbook does not create these networks, so make sure they already exist.
gitea_container_additional_networks: "{{ gitea_container_additional_networks_auto + gitea_container_additional_networks_custom }}"
# gitea_container_additional_networks_auto is reserved for usage by the playbook.
# Your custom networks should go into gitea_container_additional_networks_custom.
gitea_container_additional_networks_auto: []
gitea_container_additional_networks_custom: []

Sadly I couldn't get further with my debugging, because I don't understand how you are managing the variables in this playbook. (Maybe a developer documentation would help 😀)

Btw: I also tried it the other way round to add exim-relay to the gitea network, which also didn't work, see this PR.

I've merged that PR. It's good to have exim_relay_container_additional_networks actually working as expected.

As for integrating Gitea with exim-mailer: for other services, we usually connect the service to exim's network, not the other way around. You can see how it's done for GoToSocial here:

gotosocial_container_additional_networks_auto: |
{{
([mash_playbook_reverse_proxyable_services_additional_network] if mash_playbook_reverse_proxyable_services_additional_network else [])
+
([devture_postgres_container_network] if devture_postgres_enabled and gotosocial_database_host == devture_postgres_identifier and gotosocial_container_network != devture_postgres_container_network else [])
+
([exim_relay_container_network | default('mash-exim-relay')] if (exim_relay_enabled | default(false) and gotosocial_smtp_host == exim_relay_identifier | default('mash-exim-relay') and gotosocial_container_network != exim_relay_container_network) else [])
}}

and here:

# role-specific:exim_relay
gotosocial_smtp_host: "{{ exim_relay_identifier if exim_relay_enabled else '' }}"
gotosocial_smtp_port: 8025
gotosocial_smtp_from: "{{ exim_relay_sender_address if exim_relay_enabled else '' }}"
# /role-specific:exim_relay


This hasn't been done for the Gitea (and Forgejo) components.

We should refer to the Using SMTP configuration documentation for Gitea and introduce new Ansible variables (e.g. gitea_config_mailer_enabled, gitea_config_mailer_from, etc.) which confgure their equivalent environment variables (GITEA__mailer__ENABLED, GITEA__mailer__FROM, etc.) in Gitea's env.j2 file.

With these variables in place and working, we can update templates/group_vars_mash_servers in a similar way and wire Gitea to use exim-relay automatically.

Solved with #172