sshd_cert: Renew cert if it's close to expire
This commit is contained in:
parent
48beb781b3
commit
d4d68dc962
1 changed files with 19 additions and 1 deletions
|
@ -23,6 +23,20 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: sshd_cert_status
|
register: sshd_cert_status
|
||||||
|
|
||||||
|
- name: Get certificate info
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- ssh-keygen
|
||||||
|
- -L
|
||||||
|
- -f
|
||||||
|
- "/srv/sshca/pubkeys/{{ inventory_hostname }}-cert.pub"
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
check_mode: false
|
||||||
|
when: sshd_cert_status.stat.exists
|
||||||
|
delegate_to: localhost
|
||||||
|
register: sshd_cert_info
|
||||||
|
|
||||||
- name: Sign certificate
|
- name: Sign certificate
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
argv:
|
argv:
|
||||||
|
@ -41,7 +55,11 @@
|
||||||
- "/srv/sshca/pubkeys/{{ inventory_hostname }}.pub"
|
- "/srv/sshca/pubkeys/{{ inventory_hostname }}.pub"
|
||||||
when: >
|
when: >
|
||||||
not sshd_cert_status.stat.exists or
|
not sshd_cert_status.stat.exists or
|
||||||
sshd_cert_status.stat.mtime | int < sshd_cert_pubkey.stat.mtime | int
|
sshd_cert_status.stat.mtime | int < sshd_cert_pubkey.stat.mtime | int or
|
||||||
|
(
|
||||||
|
sshd_cert_info.stdout_lines | select('match', '^[ ]*Valid: ') |
|
||||||
|
first | split() | last | to_datetime('%Y-%m-%dT%H:%M:%S')
|
||||||
|
).strftime('%s') | int < ansible_date_time.epoch | int + 2592000
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Install certificate
|
- name: Install certificate
|
||||||
|
|
Loading…
Add table
Reference in a new issue