Skip to content
Snippets Groups Projects
Unverified Commit 1956f55a authored by Max Adamo's avatar Max Adamo
Browse files

increase crontab

parent 522b99d5
No related branches found
No related tags found
No related merge requests found
......@@ -46,44 +46,49 @@ if __name__ == "__main__":
decoded_output = cbot_out.decode("utf-8").split("\n")
provider_dir = os.path.join(BASE_DIR, acme_provider)
yaml_file = "{}/{}.yaml".format(provider_dir, acme_provider)
json_file = "{}/{}.json".format(provider_dir, acme_provider)
json_expired = "{}/{}_expired.json".format(provider_dir, acme_provider)
YAML_FILE = "{}/{}.yaml".format(provider_dir, acme_provider)
JSON_FILE = "{}/{}.json".format(provider_dir, acme_provider)
JSON_EXPIRED = "{}/{}_expired.json".format(provider_dir, acme_provider)
os.chmod(provider_dir, 0o755)
# open yaml for writing
with open(yaml_file, "w") as yaml_out:
with open(YAML_FILE, "w") as yaml_out:
yaml_out.write("---\n")
for txt_line in decoded_output:
if "Certificate Name:" in txt_line:
txt_line_out = re.sub('.*Certificate Name: ', '- certname: ', txt_line)
TXT_LINE_OUT = re.sub(
'.*Certificate Name: ', '- certname: ', txt_line)
elif "Serial Number: " in txt_line:
txt_line_out = re.sub('.*Serial Number: ', ' serial_number: ', txt_line)
TXT_LINE_OUT = re.sub(
'.*Serial Number: ', ' serial_number: ', txt_line)
elif "Domains: " in txt_line:
domains = re.sub('.*Domains: ', '', txt_line).split(" ")
domains_modified = ['"' + i + '"' for i in domains]
domains_joined = '\n - '.join(domains_modified)
txt_line_out = " domains:\n - " + domains_joined
DOMAINS_JOINED = '\n - '.join(domains_modified)
TXT_LINE_OUT = " domains:\n - " + DOMAINS_JOINED
elif "Expiry Date: " in txt_line:
txt_line_out = re.sub('.*Expiry Date: .*\(', ' expiry_date: "', txt_line) #pylint: disable=W1401
txt_line_out = txt_line_out.replace(')', '') + '"'
TXT_LINE_OUT = re.sub(
'.*Expiry Date: .*\(', ' expiry_date: "', txt_line) # pylint: disable=W1401
TXT_LINE_OUT = TXT_LINE_OUT.replace(')', '') + '"'
else:
txt_line_out = None
TXT_LINE_OUT = None
if txt_line_out:
yaml_out.write("{}\n".format(txt_line_out))
if TXT_LINE_OUT:
yaml_out.write("{}\n".format(TXT_LINE_OUT))
yaml_out.close()
# open yaml for reading and json(s) for writing
with open(yaml_file, 'r') as yaml_in, \
open(json_file, "w") as json_out, \
open(json_expired, "w") as json_exp_out:
with open(YAML_FILE, 'r') as yaml_in, \
open(JSON_FILE, "w") as json_out, \
open(JSON_EXPIRED, "w") as json_exp_out:
yaml_object = yaml.safe_load(yaml_in)
json_dumped = json.dumps(yaml_object, indent=4)
# sorting list of dictionaries by value: https://stackoverflow.com/a/73050/3151187
sorted_certname = sorted(ast.literal_eval(json_dumped), key=lambda k: k['certname'])
sorted_expired = sorted(ast.literal_eval(json_dumped), key=lambda k: k['expiry_date'])
sorted_certname = sorted(ast.literal_eval(
json_dumped), key=lambda k: k['certname'])
sorted_expired = sorted(ast.literal_eval(
json_dumped), key=lambda k: k['expiry_date'])
sorted_certname_json = json.dumps(sorted_certname, indent=4)
sorted_expired_json = json.dumps(sorted_expired, indent=4)
json_out.write(sorted_certname_json)
......@@ -96,7 +101,7 @@ if __name__ == "__main__":
timestamp_file.close()
json_out.close()
json_exp_out.close()
# os.unlink(yaml_file)
# os.unlink(YAML_FILE)
# fix permissions
os.chmod(BASE_DIR, 0o755)
......
......@@ -51,7 +51,7 @@ class geant_acme::nginx (
ensure => present,
user => 'root',
command => '/usr/bin/flock /tmp/cert2json.lock /root/bin/cert2json.py -p all',
minute => '*/5';
minute => '*/3';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment