paulbsd-salt/states/acme/templates/pkic.py.j2
Paul Lecuq a3b02771a4
All checks were successful
continuous-integration/drone/push Build is passing
created templates folder on each state
2023-03-11 10:08:26 +01:00

36 lines
814 B
Django/Jinja

#!/usr/bin/python3
# vim:syntax=python
import os
import requests
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")
MERGE=eval(os.environ.get("MERGE"))
def main():
res = requests.request(method="GET",
url=f"{URL}/domain/{DOMAINS}",
auth=(USERNAME, PASSWORD))
resj = res.json()
try:
if "certificate" in resj.keys():
with open(FULLCERTFILE, "w") as fcf:
fcf.write(resj["certificate"])
if "privatekey" in resj.keys():
with open(KEYFILE, "w") as fkf:
fkf.write(resj["privatekey"])
except Exception as e:
print(e)
return
if __name__ == "__main__":
main()