{"id":21091375,"url":"https://github.com/andreasscherbaum/ansible_check_cert_age","last_synced_at":"2025-10-13T07:32:24.242Z","repository":{"id":150258446,"uuid":"172239896","full_name":"andreasscherbaum/ansible_check_cert_age","owner":"andreasscherbaum","description":"Ansible filter which checks the age (remaining valid time) of a certificate","archived":false,"fork":false,"pushed_at":"2020-03-10T11:22:43.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T04:41:37.168Z","etag":null,"topics":["ansible","ansible-filters","lets-encrypt","letsencrypt","letsencrypt-certificates","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreasscherbaum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-02-23T17:01:05.000Z","updated_at":"2020-03-10T11:22:45.000Z","dependencies_parsed_at":"2023-04-14T17:43:47.703Z","dependency_job_id":null,"html_url":"https://github.com/andreasscherbaum/ansible_check_cert_age","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andreasscherbaum/ansible_check_cert_age","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasscherbaum%2Fansible_check_cert_age","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasscherbaum%2Fansible_check_cert_age/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasscherbaum%2Fansible_check_cert_age/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasscherbaum%2Fansible_check_cert_age/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreasscherbaum","download_url":"https://codeload.github.com/andreasscherbaum/ansible_check_cert_age/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasscherbaum%2Fansible_check_cert_age/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014119,"owners_count":26085463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-filters","lets-encrypt","letsencrypt","letsencrypt-certificates","python"],"created_at":"2024-11-19T21:45:34.119Z","updated_at":"2025-10-13T07:32:24.237Z","avatar_url":"https://github.com/andreasscherbaum.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansible_check_cert_age\n\nAnsible filter plugins which checks the age (remaining valid time) of a certificate, or if a certificate exists.\n\n\n# Installation\n\nCreate a subfolder _filter_plugins_ in your Playbook directory. Place the .py script in _filter_plugins_.\n\n\n# cert_age.py\n\n## Usage\n\nIn your Playbook, specify this filter on the certificate filename, and supply the minimum number of days the cert must be valid.\n\n### Example 1:\n\n```\n- name: Cert is valid\n  debug:\n    msg: \"{{ ('/path/to/signed.crt')|check_cert_age(15) }}\n\n```\n\nThis will print _0_ if the cert is valid for the number days, and _1_ otherwise.\n\n\n### Example 2:\n\n```\n- name: Renew cert\n  shell: ...\n  when: ('/path/to/signed.crt')|check_cert_age(15) == \"1\"\n```\n\nThis will execute the Play when the cert is about to expire.\n\n# cert_exists.py\n\n## Usage\n\nIn your Playbook, specify this filter on the certificate filename in order to find out if the certificate already exists.\nThere is no easy way to loop over many domains/certificates and make Ansible not fail the loop if the certificate does not (yet) exists.\n\nThis can be handled for a single cert, by using the _stat_ module. But in a loop this requires moving the entire code block into a separate file, and looping over the domains/certs by including the files. As of now, Ansible can't loop over code blocks with more than one tasks.\n\n### Example\n\n```\n- name: Cert exists\n  msg: \"Certificate file exists: {{ item }}\"\n  with_dict: \"{{ websites }}\"\n  loop_control:\n    loop_var: website\n    label: \"{{ website.key }}\"\n  when:\n    - (website.key + '/signed.crt')|cert_exists() == \"1\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasscherbaum%2Fansible_check_cert_age","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreasscherbaum%2Fansible_check_cert_age","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasscherbaum%2Fansible_check_cert_age/lists"}