Issue #32 renaming letsencrypt test server env var
This commit is contained in:
parent
607470a122
commit
f7969c2deb
6 changed files with 25 additions and 10 deletions
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"cSpell.words": [
|
||||
"certonly",
|
||||
"letsencrypt"
|
||||
]
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
| EASYHAPROXY_DISCOVER | How the services will be discovered to create `haproxy.cfg`: `static`, `docker`, `swarm` or `kubernetes` | **required** |
|
||||
| EASYHAPROXY_LABEL_PREFIX | (Optional) The key will search for matching resources. | `easyhaproxy` |
|
||||
| EASYHAPROXY_LETSENCRYPT_EMAIL | (Optional) The email will be used to request the certificate to Letsencrypt | *empty* |
|
||||
| EASYHAPROXY_LETSENCRYPT_STAGING | (Optional) If true, will try to connect to the Letsencrypt test server | false |
|
||||
| EASYHAPROXY_LETSENCRYPT_SERVER | (Optional) Can be true or 'schema://domain.tld'. If set, will try to connect to the Letsencrypt test server | false |
|
||||
| EASYHAPROXY_SSL_MODE | (Optional) `strict` supports only the most recent TLS version; `default` good SSL integration with recent browsers; `loose` supports all old SSL protocols for old browsers (not recommended). | `default`|
|
||||
| EASYHAPROXY_REFRESH_CONF | (Optional) Check configuration every N seconds. | 10 |
|
||||
| EASYHAPROXY_LOG_LEVEL | (Optional) The log level for EasyHAproxy messages. Available: TRACE,DEBUG,INFO,WARN,ERROR,FATAL | DEBUG |
|
||||
|
|
|
|||
|
|
@ -174,10 +174,19 @@ class DaemonizeHAProxy:
|
|||
|
||||
|
||||
class Certbot:
|
||||
def __init__(self, certs, email, staging):
|
||||
def __init__(self, certs, email, test_server):
|
||||
self.certs = certs
|
||||
self.email = email
|
||||
self.staging = staging
|
||||
self.test_server = self.set_test_server(test_server)
|
||||
|
||||
def set_test_server(self, test_server):
|
||||
if not test_server:
|
||||
return ""
|
||||
|
||||
if test_server.lower() in ["true", "1", "yes"]:
|
||||
return "--staging"
|
||||
else:
|
||||
return "--server " + test_server
|
||||
|
||||
def check_certificates(self, hosts):
|
||||
if self.email == "" or len(hosts) == 0:
|
||||
|
|
@ -202,7 +211,7 @@ class Certbot:
|
|||
Functions.log(Functions.CERTBOT_LOG, Functions.DEBUG, "Renew certificate for %s" % (host))
|
||||
renew_certs.append(host_arg)
|
||||
|
||||
certbot_certonly = ('/usr/bin/certbot certonly {staging}'
|
||||
certbot_certonly = ('/usr/bin/certbot certonly {test_server}'
|
||||
' --standalone'
|
||||
' --preferred-challenges http'
|
||||
' --http-01-port 2080'
|
||||
|
|
@ -213,7 +222,7 @@ class Certbot:
|
|||
' --max-log-backups=0'
|
||||
' {certs} --email {email}'.format(certs = ' '.join(request_certs),
|
||||
email = self.email,
|
||||
staging = '--staging' if self.staging else '')
|
||||
test_server = self.test_server)
|
||||
)
|
||||
|
||||
ret_reload = False
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ def start():
|
|||
haproxy.haproxy("start")
|
||||
haproxy.sleep()
|
||||
|
||||
certbot = Certbot(Consts.certs_letsencrypt, os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"), os.getenv("EASYHAPROXY_LETSENCRYPT_STAGING", "false").lower() in ["true", "1", "yes"])
|
||||
certbot = Certbot(Consts.certs_letsencrypt, os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"), os.getenv("EASYHAPROXY_LETSENCRYPT_SERVER", "false").lower())
|
||||
|
||||
while True:
|
||||
if old_haproxy is not None:
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ContainerEnv:
|
|||
if (os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL")):
|
||||
env_vars["letsencrypt"] = {
|
||||
"email": os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"),
|
||||
"staging": os.getenv("EASYHAPROXY_LETSENCRYPT_STAGING", "false").lower() in ["true", "1", "yes"]
|
||||
"server": os.getenv("EASYHAPROXY_LETSENCRYPT_SERVER", "false").lower() in ["true", "1", "yes"]
|
||||
}
|
||||
|
||||
return env_vars
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ def test_container_env_stats_password():
|
|||
"lookup_label": "easyhaproxy",
|
||||
"letsencrypt": {
|
||||
"email": "acme@example.org",
|
||||
"staging": False
|
||||
"server": False
|
||||
}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
|
|
@ -103,7 +103,7 @@ def test_container_env_stats_password():
|
|||
|
||||
def test_container_env_letsencrypt():
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = 'acme@example.org'
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_STAGING'] = 'true'
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_SERVER'] = 'true'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
|
|
@ -111,7 +111,7 @@ def test_container_env_letsencrypt():
|
|||
"lookup_label": "easyhaproxy",
|
||||
"letsencrypt": {
|
||||
"email": "acme@example.org",
|
||||
"staging": True
|
||||
"server": True
|
||||
}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue