updated acme state
This commit is contained in:
parent
63f22fca41
commit
947e373d18
@ -6,11 +6,11 @@ import requests
|
||||
|
||||
|
||||
def write_file_content(content=None,
|
||||
file=None):
|
||||
filename=None):
|
||||
ret = None
|
||||
|
||||
try:
|
||||
with open(file, "w") as f:
|
||||
with open(filename, "w") as f:
|
||||
ret = f.write(content)
|
||||
except Exception as err:
|
||||
pass
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from salt.utils.stringutils import get_diff
|
||||
|
||||
|
||||
def fetched(name=None,
|
||||
url="http://pki",
|
||||
username=None,
|
||||
@ -12,12 +15,12 @@ def fetched(name=None,
|
||||
'name': name,
|
||||
'changes': {},
|
||||
'result': False,
|
||||
'comment': 'Config is up to date'
|
||||
'comment': 'Config is not up to date'
|
||||
}
|
||||
|
||||
currentcert = None
|
||||
currentkey = None
|
||||
domain_concat = domains.join(',')
|
||||
domain_concat = ",".join(domains)
|
||||
|
||||
currentcert = __salt__['pki.get_file_content'](checkfile=certfile)
|
||||
currentkey = __salt__['pki.get_file_content'](checkfile=keyfile)
|
||||
@ -31,11 +34,14 @@ def fetched(name=None,
|
||||
wcert = __salt__['pki.write_file_content'](newcert, certfile)
|
||||
wkey = __salt__['pki.write_file_content'](newkey, keyfile)
|
||||
|
||||
ret["changes"]["old"] = [currentcert,currentkey].join("\n")
|
||||
ret["changes"]["new"] = [newcert,newkey].join("\n")
|
||||
ret["changes"]["diff"] = salt.utils.stringutils.get_diff([currentcert,currentkey].join("\n"),
|
||||
[newcert,newkey].join("\n"))
|
||||
ret["changes"]["old"] = "\n".join([currentcert, currentkey])
|
||||
ret["changes"]["new"] = "\n".join([newcert, newkey])
|
||||
ret["changes"]["diff"] = get_diff(ret["changes"]["old"],
|
||||
ret["changes"]["new"])
|
||||
ret["comment"] = "Updated certificates and keys"
|
||||
ret["result"] = all([wcert, wkey])
|
||||
else:
|
||||
ret["comment"] = "Config is good and not changed"
|
||||
ret["result"] = True
|
||||
|
||||
return ret
|
||||
|
@ -3,10 +3,10 @@
|
||||
---
|
||||
pki-fetched:
|
||||
pki.fetched:
|
||||
- name: /etc/acme/pkic.py
|
||||
- url: '{{ acme.provider.pki.url }}'
|
||||
- username: '{{ acme.provider.pki.username }}'
|
||||
- password: '{{ acme.provider.pki.password }}'
|
||||
- domains: '{{ acme.domains }}'
|
||||
- certfile: '{{ acme.certfile }}'
|
||||
- keyfile: '{{ acme.keyfile }}'
|
||||
- name: pkg-fetched
|
||||
- url: {{ acme.provider.pki.url }}
|
||||
- username: {{ acme.provider.pki.username }}
|
||||
- password: {{ acme.provider.pki.password }}
|
||||
- domains: {{ acme.domains }}
|
||||
- certfile: {{ acme.certfile }}
|
||||
- keyfile: {{ acme.keyfile }}
|
||||
|
Loading…
Reference in New Issue
Block a user