0
サーバー上の証明書に関する情報を取得しようとしているため、証明書の有効期限が近づいている場合に対処できます。私が取っている手順は、次のとおりです。どのようにして情報を取得することができますか?
# Does the certificate already exist?
- name: certbot | does cert already exist
stat:
path: "/etc/letsencrypt/live/{{certbot_domain}}//cert.pem"
register: certbot_certificate
# Get the expiration date for the certificate in ISO format.
- name: certbot | get cert expiration date
shell: "date --date=\"$(openssl x509 -in /etc/letsencrypt/live/{{certbot_domain}}/cert.pem -noout -enddate | cut -d= -f 2)\" --iso-8601"
register: certbot_expiration_date
when: certbot_certificate.stat.exists == True
# Convert the expiration date into the number of seconds from today.
- name: certbot | calculating expiration in seconds
shell: "echo $(($(date --date={{certbot_expiration_date.stdout}} +%s) - $(date +%s)))"
register: certbot_expires_in
when: certbot_certificate.stat.exists == True
私の問題は、シェルコマンドの両方が常にこの脚本は冪等することができないことを意味し、Ansibleに「変更」としてマークされていることです。
なぜなら、Ansibleはシェルコマンドが何をしているのかを実際に理解する方法がないため、「変更されました」と言って安全に遊んでいるからですが、偶像崇拝の方法があるのでしょうか?同じ結果を達成する?
拡張子を書くの短い、それは... :)
おかげです。