updated code security in pki state
This commit is contained in:
parent
d0d57526c8
commit
5966e77b98
@ -4,12 +4,12 @@ from salt.utils.stringutils import get_diff
|
|||||||
|
|
||||||
|
|
||||||
def fetched(name=None,
|
def fetched(name=None,
|
||||||
url="http://pki",
|
url="http://pki",
|
||||||
username=None,
|
username=None,
|
||||||
password=None,
|
password=None,
|
||||||
domains=None,
|
domains=None,
|
||||||
fullcertfile=None,
|
fullcertfile=None,
|
||||||
keyfile=None):
|
keyfile=None):
|
||||||
|
|
||||||
ret = {
|
ret = {
|
||||||
'name': name,
|
'name': name,
|
||||||
@ -31,15 +31,19 @@ def fetched(name=None,
|
|||||||
domains=domain_concat)
|
domains=domain_concat)
|
||||||
|
|
||||||
if currentcert != newcert or currentkey != newkey:
|
if currentcert != newcert or currentkey != newkey:
|
||||||
wcert = __salt__['pki.write_file_content'](newcert, fullcertfile)
|
if len(newcert) > 10 or len(newkey) > 10:
|
||||||
wkey = __salt__['pki.write_file_content'](newkey, keyfile)
|
wcert = __salt__['pki.write_file_content'](newcert, fullcertfile)
|
||||||
|
wkey = __salt__['pki.write_file_content'](newkey, keyfile)
|
||||||
|
|
||||||
ret["changes"]["old"] = "\n".join([currentcert, currentkey])
|
ret["changes"]["old"] = "\n".join([currentcert, currentkey])
|
||||||
ret["changes"]["new"] = "\n".join([newcert, newkey])
|
ret["changes"]["new"] = "\n".join([newcert, newkey])
|
||||||
ret["changes"]["diff"] = get_diff(ret["changes"]["old"],
|
ret["changes"]["diff"] = get_diff(ret["changes"]["old"],
|
||||||
ret["changes"]["new"])
|
ret["changes"]["new"])
|
||||||
ret["comment"] = "Updated certificates and keys"
|
ret["comment"] = "Updated certificates and keys"
|
||||||
ret["result"] = all([wcert, wkey])
|
ret["result"] = all([wcert, wkey])
|
||||||
|
else:
|
||||||
|
ret["comment"] = "Error fetching in certificate / key length"
|
||||||
|
return ret
|
||||||
else:
|
else:
|
||||||
ret["comment"] = "Config is good and not changed"
|
ret["comment"] = "Config is good and not changed"
|
||||||
ret["result"] = True
|
ret["result"] = True
|
||||||
|
Loading…
Reference in New Issue
Block a user