Verified Commit c3ae4eb9 authored by Pilou's avatar Pilou

tests: create subdomain when needed

inventory/group_vars/all/domain.yml should not contain the default
domain. When it does, it means the dedicated subdomain hasn't been
created yet.

Fix an error which occurs when the following test command is
executed twice, the first time without the ENOUGH_API_TOKEN
environment variable set.

    ./tests/ tox -e icinga -- --enough-no-tests --enough-no-destroy

    TASK [certificate : call lets encrypt on icinga.icinga.test] ***
    fatal: [icinga-host]: FAILED! => {
        "cmd": ["certbot", "-n", "--agree-tos", "--email", "icingaadmins@icinga.test", "-d", "icinga.icinga.test", "--nginx", "--test-cert", "certonly"],
        "msg": "non-zero return code",
        "rc": 1,
        "stderr": "Saving debug log to /var/log/letsencrypt/letsencrypt.log
                   Plugins selected: Authenticator nginx, Installer nginx
                   Unable to register an account with ACME server",

/var/log/letsencrypt/letsencrypt.log contains:

    certbot.errors.Error: The ACME server believes
    icingaadmins@icinga.test is an invalid email address. Please
    ensure it is a valid email and attempt registration again.

Fixes #267
parent 7af8be68
......@@ -2,6 +2,7 @@ import os
import pytest
import shutil
import textwrap
import yaml
from enough.common import Enough
......@@ -75,7 +76,9 @@ def pytest_sessionstart(session):
(needs_vpn, hosts) = get_hosts(session, e)
r = e.create_missings(hosts)
if len(r) > 0:
with open(f'{e.config_dir}/inventory/group_vars/all/domain.yml', 'r') as f:
data = yaml.safe_load(f)
if len(r) > 0 or data.get('domain') == domain:
if needs_vpn:
if not e.vpn_has_credentials():
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment