From 98fb52d421dbe7724ade22f04b5c6a179f248d57 Mon Sep 17 00:00:00 2001 From: ntimo Date: Sat, 9 Jul 2022 08:51:26 +0000 Subject: [PATCH] Updated to be GitHub Actions ready --- .drone.yml | 126 ------------------ .gitignore | 2 +- ci-pip-requirements.sh | 18 +++ ci-piprequierments.sh | 12 -- ci-ssh.sh | 8 -- ci.sh | 49 ++++--- fork_check.sh | 7 + group_vars/all/mailcow.yml | 74 +++------- group_vars/all/testflags.yml | 5 +- mailcow-delete-server.yml | 3 + mailcow-integration-tests.yml | 1 - mailcow-start-server.yml | 21 --- roles/docker-compose/tasks/main.yml | 9 +- .../tasks/localdev/reset_instance.yml | 19 +-- roles/mailcow-tests/tasks/main.yml | 5 - .../tasks/tests/container_image_build.yml | 34 +---- roles/mailcow-tests/tasks/tests/sendmail.yml | 13 +- .../tasks/tests/sieve_prefilter_redirect.yml | 1 + roles/mailcow-tests/tasks/tests/syncjob.yml | 1 + roles/mailcow-tests/tasks/tests/watchdog.yml | 5 +- roles/mailcow-tests/vars/main.yml | 71 ---------- roles/mailcow/defaults/main/mailcow.yml | 6 - roles/mailcow/tasks/mailcowconf.yml | 24 ---- roles/mailcow/tasks/main.yml | 10 +- 24 files changed, 108 insertions(+), 416 deletions(-) delete mode 100644 .drone.yml create mode 100755 ci-pip-requirements.sh delete mode 100755 ci-piprequierments.sh delete mode 100755 ci-ssh.sh create mode 100755 fork_check.sh diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index ca1cb26..0000000 --- a/.drone.yml +++ /dev/null @@ -1,126 +0,0 @@ ---- -kind: pipeline -name: default - -platform: - os: linux - arch: amd64 - -steps: -- name: lint - pull: default - image: timovibritannia/ansible - commands: - - ansible-lint ./ - ---- -kind: pipeline -name: publish - -platform: - os: linux - arch: amd64 - -trigger: - event: - - tag - -steps: -- name: prepare-tests - pull: default - image: timovibritannia/ansible - commands: - - chmod +x ci.sh - - chmod +x ci-tag.sh - - chmod +x ci-ssh.sh - - chmod +x ci-piprequierments.sh - - export DRONE_COMMIT=$(curl -sL https://api.github.com/repos/mailcow/mailcow-dockerized/commits/master | jq -r '.sha') - - export DRONE_GIT_HTTP_URL=https://github.com/mailcow/mailcow-dockerized.git - - ./ci.sh - - ./ci-tag.sh - - wget -O group_vars/all/secrets.yml $SECRETS_DOWNLOAD_URL --quiet - environment: - SECRETS_DOWNLOAD_URL: - from_secret: SECRETS_DOWNLOAD_URL - VAULT_PW: - from_secret: VAULT_PW - when: - event: - - tag - -- name: create-server - pull: default - image: timovibritannia/ansible - commands: - - ./ci-piprequierments.sh - - ansible-playbook mailcow-start-server.yml --diff - - ./ci-ssh.sh - environment: - ANSIBLE_HOST_KEY_CHECKING: false - ANSIBLE_FORCE_COLOR: true - when: - event: - - tag - -- name: setup-server - pull: default - image: timovibritannia/ansible - commands: - - sleep 120 - - ./ci-piprequierments.sh - - ansible-playbook mailcow-setup-server.yml --private-key /drone/src/id_ssh_rsa --diff - environment: - ANSIBLE_HOST_KEY_CHECKING: false - ANSIBLE_FORCE_COLOR: true - when: - event: - - tag - -- name: run-tests - pull: default - image: timovibritannia/ansible - commands: - - ./ci-piprequierments.sh - - ansible-playbook mailcow-integration-tests.yml --private-key /drone/src/id_ssh_rsa --diff - environment: - ANSIBLE_HOST_KEY_CHECKING: false - ANSIBLE_FORCE_COLOR: true - when: - branch: - - master - event: - - tag - -- name: delete-server - pull: default - image: timovibritannia/ansible - commands: - - ./ci-piprequierments.sh - - ansible-playbook mailcow-delete-server.yml --diff - environment: - ANSIBLE_HOST_KEY_CHECKING: false - ANSIBLE_FORCE_COLOR: true - when: - event: - - tag - status: - - failure - - success - -- name: create-release - image: plugins/github-release - settings: - api_key: - from_secret: GITHUB_API_KEY - title: ${DRONE_TAG} - note: changelogs/${DRONE_TAG}.md - overwrite: true - when: - event: - - tag - ---- -kind: signature -hmac: 08a951c75404e71c9f34079f9e17b2999934e3a7d88dbf14d4efcbf23f03978e - -... diff --git a/.gitignore b/.gitignore index aea27e4..2fea9dc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ keys/* hostvars.yml id_ssh_rsa id_ssh_rsa.pub -group_vars/all/secrets.yml +group_vars/all/secrets*.yml group_vars/all/localdev_conf.yml node_modules/* package-lock.json diff --git a/ci-pip-requirements.sh b/ci-pip-requirements.sh new file mode 100755 index 0000000..d79629a --- /dev/null +++ b/ci-pip-requirements.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Author: ntimo + +# Install requierments +echo "Installing pip requirements" +echo "" +sudo pip3 install hcloud +sudo pip3 install jmespath +sudo pip3 install docker + +# Install Ansible +echo "" +echo "" +echo "Installing Ansible Galaxy requirements" +echo "" +ansible-galaxy collection install community.general +ansible-galaxy collection install hetzner.hcloud diff --git a/ci-piprequierments.sh b/ci-piprequierments.sh deleted file mode 100755 index e099099..0000000 --- a/ci-piprequierments.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Author: ntimo - -# Install requierments -pip3 install hcloud > /dev/null -pip3 install jmespath > /dev/null -pip3 install docker > /dev/null - -# Install Ansible -ansible-galaxy collection install community.general > /dev/null -ansible-galaxy collection install hetzner.hcloud > /dev/null diff --git a/ci-ssh.sh b/ci-ssh.sh deleted file mode 100755 index a74199a..0000000 --- a/ci-ssh.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Author: ntimo - -SSHKEYFILE=/drone/src/id_ssh_rsa -if [ -f "$SSHKEYFILE" ]; then - chmod 0600 $SSHKEYFILE -fi diff --git a/ci.sh b/ci.sh index e438097..132c19d 100755 --- a/ci.sh +++ b/ci.sh @@ -2,31 +2,36 @@ # Author: ntimo -# Set permissions -chmod +x ./namegenerator.sh -chmod -R 0744 /drone/src/* -SSHKEYFILE=/drone/src/id_ssh_rsa -if [ -f "$SSHKEYFILE" ]; then - chmod 0600 $SSHKEYFILE -fi - +echo "" +echo "Writing vault password" if [ -z "$VAULT_PW" ]; then echo "VAULT_PW is not set" exit 1 else - echo "$VAULT_PW" > /drone/src/.vault-pw + echo "$VAULT_PW" > ./.vault-pw +fi + +echo "" +echo "Writing vault file" +if [ -z "$VAULT_FILE" ]; then + echo "VAULT_FILE is not set" + exit 1 +else + echo $VAULT_FILE | sed 's/ /\n/g' | base64 --decode > ./group_vars/all/secrets.yml fi +echo "" +echo "Generating CI/CD vars" # Set global ansible variables -echo "ci_hcloud_server_name: cowintg${DRONE_COMMIT:0:10}" > /drone/src/group_vars/all/drone_servername.yml -echo "ci_drone_commit_hash: ${DRONE_COMMIT:0:10}" > /drone/src/group_vars/all/drone_commit_hash.yml -echo "ci_drone_commit_hash_long: ${DRONE_COMMIT}" > /drone/src/group_vars/all/drone_commit_hash_long.yml -echo "ci_mailcow__mailbox_user_one: $(./namegenerator.sh)" > /drone/src/group_vars/all/drone_mailcow__mailbox_user_one.yml -echo "ci_mailcow__mailbox_user_two: $(./namegenerator.sh)" > /drone/src/group_vars/all/drone_mailcow_mailcow__mailbox_user_two.yml -echo "ci_mailcow__mailbox_user_alias: $(./namegenerator.sh)" > /drone/src/group_vars/all/drone_mailcow__mailbox_user_alias.yml -echo "ci_mailcow__api_key: $(openssl rand -hex 25)" > /drone/src/group_vars/all/drone_mailcow__api_key.yml -echo "ci_mailcow__api_key_read_only: $(openssl rand -hex 25)" > /drone/src/group_vars/all/drone_mailcow__api_key_read_only.yml -echo "ci_mailcow__upload_results: true" > /drone/src/group_vars/all/mailcow__upload_results.yml +echo "ci_hcloud_server_name: cowintg${GITHUB_SHA:0:10}" > ./group_vars/all/drone_servername.yml +echo "ci_drone_commit_hash: ${GITHUB_SHA:0:10}" > ./group_vars/all/drone_commit_hash.yml +echo "ci_drone_commit_hash_long: ${GITHUB_SHA}" > ./group_vars/all/drone_commit_hash_long.yml +echo "ci_mailcow__mailbox_user_one: $(./namegenerator.sh)" > ./group_vars/all/drone_mailcow__mailbox_user_one.yml +echo "ci_mailcow__mailbox_user_two: $(./namegenerator.sh)" > ./group_vars/all/drone_mailcow_mailcow__mailbox_user_two.yml +echo "ci_mailcow__mailbox_user_alias: $(./namegenerator.sh)" > ./group_vars/all/drone_mailcow__mailbox_user_alias.yml +echo "ci_mailcow__api_key: $(openssl rand -hex 25)" > ./group_vars/all/drone_mailcow__api_key.yml +echo "ci_mailcow__api_key_read_only: $(openssl rand -hex 25)" > ./group_vars/all/drone_mailcow__api_key_read_only.yml +echo "ci_mailcow__upload_results: true" > ./group_vars/all/mailcow__upload_results.yml domains[0]="4884884.xyz" domains[0]="8448448.xyz" @@ -34,7 +39,7 @@ domains_size=${#domains[@]} domains_index=$(($RANDOM % $domains_size)) # set env specific ansible variables -echo "ci_mailcow__dns_zone: ${domains[$domains_index]}" > /drone/src/group_vars/all/drone_mailcow__demo_domain.yml -echo "ci_mailcow__git_repo: ${DRONE_GIT_HTTP_URL}" > /drone/src/group_vars/all/drone_mailcow__git_repo.yml -echo "ci_mailcow__git_http_url: ${DRONE_GIT_HTTP_URL:: -4}" > /drone/src/group_vars/all/drone_mailcow__git_http_url.yml -echo "ci_mailcow__git_version: ${DRONE_COMMIT}" > /drone/src/group_vars/all/drone_mailcow__git_version.yml +echo "ci_mailcow__dns_zone: ${domains[$domains_index]}" > ./group_vars/all/drone_mailcow__demo_domain.yml +echo "ci_mailcow__git_repo: https://github.com/${GITHUB_REPOSITORY}.git" > ./group_vars/all/drone_mailcow__git_repo.yml +echo "ci_mailcow__git_http_url: https://github.com/${GITHUB_REPOSITORY}" > ./group_vars/all/drone_mailcow__git_http_url.yml +echo "ci_mailcow__git_version: ${GITHUB_SHA}" > ./group_vars/all/drone_mailcow__git_version.yml diff --git a/fork_check.sh b/fork_check.sh new file mode 100755 index 0000000..c6c5f0d --- /dev/null +++ b/fork_check.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "Running Integration Test project in ${GITHUB_REPOSITORY}" +if [[ "${GITHUB_REPOSITORY}" != "mailcow/mailcow-dockerized" ]]; then + echo "This can't be run in a fork" + exit 1 +fi diff --git a/group_vars/all/mailcow.yml b/group_vars/all/mailcow.yml index 3574c38..05487b4 100644 --- a/group_vars/all/mailcow.yml +++ b/group_vars/all/mailcow.yml @@ -11,44 +11,6 @@ mailcow__config_skip_http_verification: y mailcow__upload_results_html: yes mailcow__upload_results_json: yes -mailcow__lang_files: - - name: CA - file: lang.ca.json - - name: CS - file: lang.cs.json - - name: DE - file: lang.de.json - - name: ES - file: lang.es.json - - name: FI - file: lang.fi.json - - name: FR - file: lang.fr.json - - name: IT - file: lang.it.json - - name: LV - file: lang.lv.json - - name: NL - file: lang.nl.json - - name: PL - file: lang.pl.json - - name: PT - file: lang.pt.json - - name: RO - file: lang.ro.json - - name: RU - file: lang.ru.json - - name: SV - file: lang.sv.json - - name: SK - file: lang.sk.json - - name: HU - file: lang.hu.json - - name: KO - file: lang.ko.json - - name: ZH - file: lang.zh.json - mailcow__pull_images: - mysql-mailcow - redis-mailcow @@ -77,24 +39,24 @@ mailcow__docker_logs_directory: /opt/mailcow-logs mailcow__docker_logs_archive_path: "/opt/{{ mailcow__docker_logs_archive_name }}" mailcow__docker_logs_archive_name: logs-{{ drone_commit_hash }}-{{ mailcow__report_timestamp }}.zip mailcow__container_names: - - mailcowdockerized_acme-mailcow_1 - - mailcowdockerized_clamd-mailcow_1 - - mailcowdockerized_dockerapi-mailcow_1 - - mailcowdockerized_dovecot-mailcow_1 - - mailcowdockerized_ipv6nat-mailcow_1 - - mailcowdockerized_memcached-mailcow_1 - - mailcowdockerized_mysql-mailcow_1 - - mailcowdockerized_netfilter-mailcow_1 - - mailcowdockerized_nginx-mailcow_1 - - mailcowdockerized_olefy-mailcow_1 - - mailcowdockerized_php-fpm-mailcow_1 - - mailcowdockerized_postfix-mailcow_1 - - mailcowdockerized_redis-mailcow_1 - - mailcowdockerized_rspamd-mailcow_1 - - mailcowdockerized_sogo-mailcow_1 - - mailcowdockerized_solr-mailcow_1 - - mailcowdockerized_unbound-mailcow_1 - - mailcowdockerized_watchdog-mailcow_1 + - mailcowdockerized-acme-mailcow-1 + - mailcowdockerized-clamd-mailcow-1 + - mailcowdockerized-dockerapi-mailcow-1 + - mailcowdockerized-dovecot-mailcow-1 + - mailcowdockerized-ipv6nat-mailcow-1 + - mailcowdockerized-memcached-mailcow-1 + - mailcowdockerized-mysql-mailcow-1 + - mailcowdockerized-netfilter-mailcow-1 + - mailcowdockerized-nginx-mailcow-1 + - mailcowdockerized-olefy-mailcow-1 + - mailcowdockerized-php-fpm-mailcow-1 + - mailcowdockerized-postfix-mailcow-1 + - mailcowdockerized-redis-mailcow-1 + - mailcowdockerized-rspamd-mailcow-1 + - mailcowdockerized-sogo-mailcow-1 + - mailcowdockerized-solr-mailcow-1 + - mailcowdockerized-unbound-mailcow-1 + - mailcowdockerized-watchdog-mailcow-1 mailcow__hostname_local_part: "mail-{{ drone_commit_hash }}" mailcow__hostname: "{{ mailcow__hostname_local_part }}.{{ mailcow__dns_zone }}" diff --git a/group_vars/all/testflags.yml b/group_vars/all/testflags.yml index 2af083a..4093954 100644 --- a/group_vars/all/testflags.yml +++ b/group_vars/all/testflags.yml @@ -16,10 +16,7 @@ mailcow__tests_test_sendmail: yes mailcow__tests_test_app_password: yes # tests/syncjob.yml -mailcow__tests_test_syncjob: yes - -# tests/lang_coverage.yml -mailcow_tests__test_langcoverage: yes +mailcow__tests_test_syncjob: no # tests/oauth_apps.yml mailcow_tests__oauth_apps: yes diff --git a/mailcow-delete-server.yml b/mailcow-delete-server.yml index 65af282..827b441 100644 --- a/mailcow-delete-server.yml +++ b/mailcow-delete-server.yml @@ -20,6 +20,7 @@ location: "{{ item.datacenter }}" state: absent api_token: "{{ vault__hcloud__token }}" + when: "'{{ ci_hcloud_server_name }}' in item.name" loop: "{{ hetzner_cloud_stats.hcloud_server_info }}" no_log: yes @@ -28,7 +29,9 @@ name: "{{ item.name }}" state: absent api_token: "{{ vault__hcloud__token }}" + when: "'{{ ci_hcloud_server_name }}' in item.name" loop: "{{ hetzner_cloud_stats.hcloud_server_info }}" + no_log: yes - name: "Delete a record for {{ mailcow__hostname }}" community.general.cloudflare_dns: diff --git a/mailcow-integration-tests.yml b/mailcow-integration-tests.yml index b91f09c..06ee36e 100755 --- a/mailcow-integration-tests.yml +++ b/mailcow-integration-tests.yml @@ -2,7 +2,6 @@ - name: Integration Tests hosts: all gather_facts: true - become: yes roles: - role: mailcow-tests tags: [ 'mailcow-tests' ] diff --git a/mailcow-start-server.yml b/mailcow-start-server.yml index 5a49fa4..765baee 100644 --- a/mailcow-start-server.yml +++ b/mailcow-start-server.yml @@ -10,27 +10,6 @@ name: hcloud state: present - - name: Gather hcloud server infos - hcloud_server_info: - api_token: "{{ vault__hcloud__token }}" - register: hetzner_cloud_stats - - - name: Delete all mailcow integration test servers - hetzner.hcloud.hcloud_server: - name: "{{ item.name }}" - location: "{{ item.datacenter }}" - state: absent - api_token: "{{ vault__hcloud__token }}" - loop: "{{ hetzner_cloud_stats.hcloud_server_info }}" - no_log: yes - - - name: Delete SSH Key from hcloud - hetzner.hcloud.hcloud_ssh_key: - name: "{{ item.name }}" - state: absent - api_token: "{{ vault__hcloud__token }}" - loop: "{{ hetzner_cloud_stats.hcloud_server_info }}" - - name: Generate SSH Key openssh_keypair: path: "{{ playbook_dir }}/id_ssh_rsa" diff --git a/roles/docker-compose/tasks/main.yml b/roles/docker-compose/tasks/main.yml index 189809c..edbff0e 100755 --- a/roles/docker-compose/tasks/main.yml +++ b/roles/docker-compose/tasks/main.yml @@ -1,13 +1,8 @@ --- + - name: Install docker-compose become: yes get_url: url: "https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64" dest: /usr/local/bin/docker-compose - mode: 0755 - -- name: Install docker-compose pip module - become: yes - pip: - name: docker-compose - state: present + mode: "a+x" diff --git a/roles/mailcow-tests/tasks/localdev/reset_instance.yml b/roles/mailcow-tests/tasks/localdev/reset_instance.yml index 5367c89..50f1ba7 100644 --- a/roles/mailcow-tests/tasks/localdev/reset_instance.yml +++ b/roles/mailcow-tests/tasks/localdev/reset_instance.yml @@ -2,12 +2,9 @@ - name: Stop mailcow container stack become: yes - community.general.docker_compose: - project_src: /opt/mailcow-dockerized - project_name: mailcowdockerized - state: absent - build: no - pull: no + shell: docker-compose down + args: + chdir: /opt/mailcow-dockerized - name: Remove docker volumes become: yes @@ -16,13 +13,11 @@ - name: Start mailcow container stack become: yes - community.general.docker_compose: - project_src: /opt/mailcow-dockerized - project_name: mailcowdockerized - state: present - build: no - pull: no + shell: docker-compose up -d + args: + chdir: /opt/mailcow-dockerized - name: Wait 120 seconds before starting tests wait_for: timeout: 120 + delegate_to: localhost diff --git a/roles/mailcow-tests/tasks/main.yml b/roles/mailcow-tests/tasks/main.yml index 8dbff1f..ce4092e 100644 --- a/roles/mailcow-tests/tasks/main.yml +++ b/roles/mailcow-tests/tasks/main.yml @@ -97,11 +97,6 @@ import_tasks: reports/docker_logs.yml tags: docker_logs -- name: Run docker image build tests - import_tasks: tests/container_image_build.yml - when: mailcow__tests_docker_image_build - tags: docker_image_build - - name: Generate report mailcow.email import_tasks: reports/generate_mailcowemail.yml diff --git a/roles/mailcow-tests/tasks/tests/container_image_build.yml b/roles/mailcow-tests/tasks/tests/container_image_build.yml index 95a2853..2c34c86 100644 --- a/roles/mailcow-tests/tasks/tests/container_image_build.yml +++ b/roles/mailcow-tests/tasks/tests/container_image_build.yml @@ -1,13 +1,11 @@ --- +# Deprecated and not used anymore! - name: Stop mailcow container stack become: yes - community.general.docker_compose: - project_src: /opt/mailcow-dockerized - project_name: mailcowdockerized - state: absent - build: no - pull: no + shell: docker-compose down + args: + chdir: /opt/mailcow-dockerized - name: Remove docker images and containers become: yes @@ -277,30 +275,6 @@ when: (result_mailcow__build_olefy_success is undefined) # end olefy -# begin ejabberd -- name: Build ejabberd-mailcow image - become: yes - command: docker-compose build ejabberd-mailcow - args: - chdir: /opt/mailcow-dockerized - register: result_mailcow__build_ejabberd - ignore_errors: yes - -- name: Print build output - debug: - var: result_mailcow__build_ejabberd - -- name: Eval test success - set_fact: - result_mailcow__build_ejabberd_success: success - when: result_mailcow__build_ejabberd.rc == 0 - -- name: Eval test failure - set_fact: - result_mailcow__build_ejabberd_success: failed - when: (result_mailcow__build_ejabberd_success is undefined) -# end ejabberd - # begin rspamd - name: Build rspamd-mailcow image become: yes diff --git a/roles/mailcow-tests/tasks/tests/sendmail.yml b/roles/mailcow-tests/tasks/tests/sendmail.yml index 90f047b..8e3a67d 100644 --- a/roles/mailcow-tests/tasks/tests/sendmail.yml +++ b/roles/mailcow-tests/tasks/tests/sendmail.yml @@ -60,19 +60,26 @@ headers: X-API-Key: "{{ mailcow__api_key }}" register: result_sendmail_rspamd + until: + - ('json' in result_sendmail_rspamd) + retries: 5 + delay: 10 + ignore_errors: yes - set_fact: result_sendmail_rspamd_symbols_list: "{{ result_sendmail_rspamd.json[0].symbols | list }}" + ignore_errors: yes - name: Debug Rspamd symbols as list debug: var: result_sendmail_rspamd_symbols_list + ignore_errors: yes ## Symbol Checks - name: Eval test success set_fact: result_sendmail_rspamd_symbols_mailcow_auth_sucess: success - when: ('MAILCOW_AUTH' in result_sendmail_rspamd_symbols_list) + when: ('MAILCOW_AUTH' in result_sendmail_rspamd_symbols_list) and (result_sendmail_rspamd_symbols_list is defined) - name: Eval test failure set_fact: @@ -82,7 +89,7 @@ - name: Eval test success set_fact: result_sendmail_rspamd_symbols_dyn_rl_check_sucess: success - when: ('DYN_RL_CHECK' in result_sendmail_rspamd_symbols_list) + when: ('DYN_RL_CHECK' in result_sendmail_rspamd_symbols_list) and (result_sendmail_rspamd_symbols_list is defined) - name: Eval test failure set_fact: @@ -92,7 +99,7 @@ - name: Eval test success set_fact: result_sendmail_rspamd_symbols_dkim_signed_sucess: success - when: ('DKIM_SIGNED' in result_sendmail_rspamd_symbols_list) + when: ('DKIM_SIGNED' in result_sendmail_rspamd_symbols_list) and (result_sendmail_rspamd_symbols_list is defined) - name: Eval test failure set_fact: diff --git a/roles/mailcow-tests/tasks/tests/sieve_prefilter_redirect.yml b/roles/mailcow-tests/tasks/tests/sieve_prefilter_redirect.yml index 9856e89..6ea76a5 100644 --- a/roles/mailcow-tests/tasks/tests/sieve_prefilter_redirect.yml +++ b/roles/mailcow-tests/tasks/tests/sieve_prefilter_redirect.yml @@ -37,6 +37,7 @@ - name: Wait 10 seconds before grabbing the rspamd logs wait_for: timeout: 10 + delegate_to: localhost # Get Rspamd Symbols - name: Get Rspamd log using API diff --git a/roles/mailcow-tests/tasks/tests/syncjob.yml b/roles/mailcow-tests/tasks/tests/syncjob.yml index fad77b7..194e603 100644 --- a/roles/mailcow-tests/tasks/tests/syncjob.yml +++ b/roles/mailcow-tests/tasks/tests/syncjob.yml @@ -22,6 +22,7 @@ - name: Wait 2 minutes before grabbing the syncjob logs wait_for: timeout: 120 + delegate_to: localhost - name: Get syncjob logs uri: diff --git a/roles/mailcow-tests/tasks/tests/watchdog.yml b/roles/mailcow-tests/tasks/tests/watchdog.yml index 389bf22..d8e6b17 100644 --- a/roles/mailcow-tests/tasks/tests/watchdog.yml +++ b/roles/mailcow-tests/tasks/tests/watchdog.yml @@ -9,6 +9,7 @@ - name: Wait 120 seconds wait_for: timeout: 120 + delegate_to: localhost - name: Get watchdog log using API uri: @@ -37,6 +38,7 @@ - ('service' in item) and ('Postfix' in item.service) - ('lvl' in item) and ('100' not in item.lvl) loop: "{{ result_watchdog_log.json | json_query('[*]') }}" + ignore_errors: yes - set_fact: result_watchdog_log_success: failed @@ -47,10 +49,11 @@ - name: Wait 300 seconds wait_for: timeout: 300 + delegate_to: localhost - name: Check if container is running again become: yes - command: docker inspect -f {% raw %}'{{.State.Running}}'{% endraw %} mailcowdockerized_postfix-mailcow_1 + command: docker inspect -f {% raw %}'{{.State.Running}}'{% endraw %} mailcowdockerized-postfix-mailcow-1 args: chdir: /opt/mailcow-dockerized register: result_watchdog_container_state diff --git a/roles/mailcow-tests/vars/main.yml b/roles/mailcow-tests/vars/main.yml index d1a627b..ff63648 100644 --- a/roles/mailcow-tests/vars/main.yml +++ b/roles/mailcow-tests/vars/main.yml @@ -291,74 +291,3 @@ mailcow_test_results: result: "{{ result_acme_certificate_sucess | default('Test result could not be determiend') }}" log: "{{ result_acme_certificate.stdout | default('Test result could not be determiend') }}" allow_failure: no -# container builds - - container_unbound: - name: "Container build: unbound" - result: "{{ result_mailcow__build_unbound_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_unbound.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_clamd: - name: "Container build: clamd" - result: "{{ result_mailcow__build_clamd_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_clamd.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_php_fpm: - name: "Container build: php-fpm" - result: "{{ result_mailcow__build_php_fpm_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_php_fpm.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_dovecot: - name: "Container build: dovecot" - result: "{{ result_mailcow__build_dovecot_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_dovecot.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_postfix: - name: "Container build: postfix" - result: "{{ result_mailcow__build_postfix_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_postfix.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_acme: - name: "Container build: acme" - result: "{{ result_mailcow__build_acme_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_acme.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_netfilter: - name: "Container build: netfilter" - result: "{{ result_mailcow__build_netfilter_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_netfilter.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_watchdog: - name: "Container build: watchdog" - result: "{{ result_mailcow__build_watchdog_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_watchdog.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_dockerapi: - name: "Container build: dockerapi" - result: "{{ result_mailcow__build_dockerapi_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_dockerapi.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_solr: - name: "Container build: solr" - result: "{{ result_mailcow__build_solr_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_solr.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_olefy: - name: "Container build: olefy" - result: "{{ result_mailcow__build_olefy_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_olefy.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_ejabberd: - name: "Container build: ejabberd" - result: "{{ result_mailcow__build_ejabberd_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_ejabberd.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_rspamd: - name: "Container build: rspamd" - result: "{{ result_mailcow__build_rspamd_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_rspamd.stdout | default('Test result could not be determiend') }}" - allow_failure: no - - container_sogo: - name: "Container build: sogo" - result: "{{ result_mailcow__build_sogo_success | default('Test result could not be determiend') }}" - log: "{{ result_mailcow__build_sogo.stdout | default('Test result could not be determiend') }}" - allow_failure: no diff --git a/roles/mailcow/defaults/main/mailcow.yml b/roles/mailcow/defaults/main/mailcow.yml index 0c9a053..4d69698 100644 --- a/roles/mailcow/defaults/main/mailcow.yml +++ b/roles/mailcow/defaults/main/mailcow.yml @@ -4,12 +4,6 @@ # Mailcow.conf # ------------- -mailcow__config_http_port: 80 -mailcow__config_http_bind: 0.0.0.0 -mailcow__config_https_port: 443 -mailcow__config_https_bind: 0.0.0.0 - - # Set this to "allow" to enable the anyone pseudo user. Disabled by default. # When enabled, ACL can be created, that apply to "All authenticated users" # This should probably only be activated on mail hosts, that are used exclusivly by one organisation. diff --git a/roles/mailcow/tasks/mailcowconf.yml b/roles/mailcow/tasks/mailcowconf.yml index 09a2e87..4e81e67 100644 --- a/roles/mailcow/tasks/mailcowconf.yml +++ b/roles/mailcow/tasks/mailcowconf.yml @@ -1,29 +1,5 @@ --- -- name: Configure HTTP_PORT - replace: - path: /opt/mailcow-dockerized/mailcow.conf - regexp: "^HTTP_PORT=.*" - replace: "HTTP_PORT={{ mailcow__config_http_port }}" - -- name: Configure HTTP_BIND - replace: - path: /opt/mailcow-dockerized/mailcow.conf - regexp: "^HTTP_BIND=.*" - replace: "HTTP_BIND={{ mailcow__config_http_bind }}" - -- name: Configure HTTPS_PORT - replace: - path: /opt/mailcow-dockerized/mailcow.conf - regexp: "^HTTPS_PORT=.*" - replace: "HTTPS_PORT={{ mailcow__config_https_port }}" - -- name: Configure HTTPS_BIND - replace: - path: /opt/mailcow-dockerized/mailcow.conf - regexp: "^HTTPS_BIND=.*" - replace: "HTTPS_BIND={{ mailcow__config_https_bind }}" - - name: Configure ACL_ANYONE replace: path: /opt/mailcow-dockerized/mailcow.conf diff --git a/roles/mailcow/tasks/main.yml b/roles/mailcow/tasks/main.yml index 095201b..3d88715 100755 --- a/roles/mailcow/tasks/main.yml +++ b/roles/mailcow/tasks/main.yml @@ -87,12 +87,10 @@ - name: Start mailcow container stack become: yes - community.general.docker_compose: - project_src: /opt/mailcow-dockerized - project_name: mailcowdockerized - state: present - build: no - pull: no + shell: | + docker-compose up -d + args: + chdir: /opt/mailcow-dockerized - name: Check if mailcow is up and returns status code 200 uri: