mailcow / mailcow-ansiblerole Goto Github PK
View Code? Open in Web Editor NEWThe official ansible role to setup mailcow using Ansible
License: GNU General Public License v3.0
The official ansible role to setup mailcow using Ansible
License: GNU General Public License v3.0
After upgrading to the newest mailcow-ansiblerole, my playbook failed with:
TASK [mailcow : Configure WATCHDOG_EXTERNAL_CHECKS]
fatal: [xxx]: FAILED! => {"changed": false, "msg": "Path /opt/mailcow-dockerized/mailcow.conf does not exist !", "rc": 257}
Seems in https://github.com/mailcow/mailcow-ansiblerole/blob/master/tasks/mailcowconf.yml#L138 is a hardcoded path
In main.yml
task Generate mailcow.conf file
calls ./generate_config.sh but if that fails at any point, re-running the playbook does not rebuild mailcow.conf
since that script checks if mailcow.conf is already installed so the config will be left broken and not as defined when calling.
Technically the playbook should respect the changes set when calling it and override the variables set in mailcow.conf
, but that would also likely break stuff, so my suggest solution would be adding a check what the variables already exists and if they differ, then the playbook should probably exit with an error, since otherwise it will succeed and silently keep incorrect configuration.
I just tried to update mailcow and had the update task skipped. Looked like the container name was different on my system than the task check below:
mailcow-ansiblerole/tasks/main.yml
Line 56 in 3968ac4
My containers were called "{{ mailcow__docker_compose_project_name }}-nginx-mailcow-1" (dashes instead of underscores). Not sure if my setup was just weird, and I already fixed it for me, but maybe there's more to it and others are affected.
installing mailcow via this role just broke for me - the role checks whether /opt/mailcow-dockerized exists and only checks out git if the folder is not there yet.
I created a btrfs subvolume and mounted it to /opt/mailcow-dockerized beforehand...
I suggest checking for existance of /opt/mailcow/dockerized/.git instead - following up with a PR...
Currently this role only supports the docker-compose standalone version. The Docker plugin version is installed automatically in the installation script as described https://docs.mailcow.email/i_u_m/i_u_m_install/#docker-compose these days. This role should at least support the Docker plugin version as of this.
@ntimo Your account is the only one which commited to this repo as part of the mailcow org. Could you clarify the term "The official ansible role" from the "About Me" section of this repository? I've the feeling that some things here are not up to date. I'd be happy to help out but would like to know how this role is handled currently. Looking at the repo only, it feels more like community-supported and not "official".
The title says it all
Hello,
thanks for making this role available!
It seems due to some changes in ansible docker_container_info and docker_compose are no longer builtin.
On Ubuntu 20.04 with ansible installed via the ppa, I had to install the collections community.docker and community.netcommon (since the filter ipaddr was not available) and apply the following changes:
diff --git a/tasks/main.yml b/tasks/main.yml
index 581fea0..cc5f130 100755
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -9,7 +9,7 @@
- name: Install required pip packages
become: yes
pip:
- name: docker
+ name: docker-compose
state: present
- name: Check if mailcow installation directory exists
@@ -56,13 +56,13 @@
- name: Check if mailcow is running
become: yes
- docker_container_info:
+ community.docker.docker_container_info:
name: "{{ mailcow__docker_compose_project_name }}_nginx-mailcow_1"
register: mailcow_running
- name: Start mailcow stack
become: yes
- docker_compose:
+ community.docker.docker_compose:
project_src: "{{ mailcow__install_path }}"
project_name: "{{ mailcow__docker_compose_project_name }}"
state: present
I also had to change the pip installation from docker to docker-compose since, although I installed docker-compose before running this role it complained that the pip package was missing. Installing docker-compose via pip seems to pull in docker as a dependency. Which seems to satisfy all dependencies for community.docker.docker_compose.
Since I am rather new to ansible I don't know if it is possible to modify the role in a way that it works for ansible 2.9 and 2.10 - therefore I choose to create just an issue and not a PR.
After installing the collections and applying the three changes the role worked as expected.
best regards,
Paul
Playbook main.yml
calls generate_config.sh which checks the amount of available ram, if there is less than 2097152 (of some unit) the script will get infinitely stuck at row 105 and 125 on generate_config.sh
The play is currently like this:
- name: Generate mailcow.conf file
shell: ./generate_config.sh
environment:
MAILCOW_HOSTNAME: "{{ mailcow__hostname }}"
MAILCOW_TZ: "{{ mailcow__timezone }}"
MAILCOW_BRANCH: "{{ mailcow__git_version }}"
args:
executable: /bin/bash
chdir: "{{ mailcow__install_path }}"
creates: mailcow.conf
tags:
- skip_ansible_lint
On Ansible role side I'd suggest for fixing it for example by adding a timeout, like below (didn't yet test) and additionally mentioning somewhere that the role does not support (yet) these cases where installed memory is less than x amount:
- name: Generate mailcow.conf file
shell: ./generate_config.sh
environment:
MAILCOW_HOSTNAME: "{{ mailcow__hostname }}"
MAILCOW_TZ: "{{ mailcow__timezone }}"
MAILCOW_BRANCH: "{{ mailcow__git_version }}"
args:
executable: /bin/bash
chdir: "{{ mailcow__install_path }}"
creates: mailcow.conf
tags:
- skip_ansible_lint
async: 60
poll: 5
A proper fix would be to modify generate_config.sh
to handle these situations without interactions.
Hey,
Is there a way via the role to configure subdomains like webmail.* or admin.*?
Best regards
boberbeck
The last publish of this role in Ansible Galaxy is over a year ago.
Could someone publish the latest state to galaxy as well please? :)
When running the mailcow-ansiblerole on Ubuntu 22.04 I receive the following error:
fatal: [redacted]: FAILED! => {"msg": "Failed to import the required Python library (netaddr) on <redacted>'s Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
This occurs after setting mailcow__config_http_bind: 127.0.0.1
. It seems to be caused by line 26 in mailcowconf.yml.
No matter if I install netaddr using apt install python3-netaddr
or pipx install netaddr
the error remains.
I did not override ansible_python_interpreter
.
The ./generate_config.sh
script blocks on the clamd check when memory is < 2.5G and prompts the user to decide whether to skip clamd. With Ansible, this makes the task hang.
Instead, it should probably respect my mailcow__config_skip_clamd
setting.
It has Come to my attention that a lot of the mailcow apps don't have a license. Is it possible to add one?
Hello,
I'm actually working on Ansible since o discovered this tool, and i have to admit this is a good deployement tool
I would like to use that role to deploy my mailcow stack on my eventuals future server reinstallation (i mean we never know what can happen)
Only problem is that i use Traefik for quite everything, and if traefik usage with docker-compose is quite easy, using traefik with this ansible role is a bit more complicated, as it needs to edit the compose file, add an override, and, the easiest part as this is done with env, change mailcow.conf values.
I'll probably give a look into that from time to time, in case I can do it myself, but if someone manage to do a correct PR/MR to add the ability to use Traefik, it would be really nice :D
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.