updated acme state

This commit is contained in:
Paul 2021-01-30 13:06:11 +01:00
parent 41d28c1a40
commit 5b28b1c382
2 changed files with 15 additions and 12 deletions

View File

@ -4,25 +4,27 @@
import os
import requests
URL=os.environ("URL")
DOMAINS=os.environ("DOMAINS")
FULLCERTFILE=os.environ("FULLCERTFILE")
KEYFILE=os.environ("KEYFILE")
USERNAME=os.environ("USERNAME")
PASSWORD=os.environ("PASSWORD")
URL=os.environ.get("URL")
DOMAINS=os.environ.get("DOMAINS")
FULLCERTFILE=os.environ.get("FULLCERTFILE")
KEYFILE=os.environ.get("KEYFILE")
USERNAME=os.environ.get("USERNAME")
PASSWORD=os.environ.get("PASSWORD")
def main():
res = requests.request(method="GET", url=f"{URL}/domain/{DOMAINS}", auth=(USERNAME, PASSWORD))
resj = res.json()
try:
with open(FULLCERTFILE) as fcf:
os.write(ffcf, resj["certificate"])
if "certificate" in resj.keys():
with open(FULLCERTFILE, "w") as fcf:
fcf.write(resj["certificate"])
with open(KEYFILE) as fkf:
os.write(fkf, resj["privatekey"])
if "privatekey" in resj.keys():
with open(KEYFILE, "w") as fkf:
fkf.write(resj["privatekey"])
except Exception as e:
return e
print(e)
return

View File

@ -13,9 +13,10 @@ pkic-run:
- name: /etc/acme/pkic.py
- env:
- URL: '{{ acme.provider.pki.url }}'
- DOMAINS: '{{ acme.domains|join(',') }}'
- FULLCERTFILE: '{{ acme.fullcertfile }}'
- KEYFILE: '{{ acme.keyfile }}'
- USERNAME: '{{ acme.provider.pki.username }}'
- PASSWORD: '{{ acme.provider.pki.password }}'
- require:
- cmd: pkic-install
- file: pkic-install