summaryrefslogtreecommitdiff
path: root/lib/chef/resource/openssl_x509_certificate.rb
diff options
context:
space:
mode:
authorJulien Huon <julien@huon.email>2019-12-25 15:08:10 +0100
committerJulien Huon <julien@huon.email>2019-12-25 15:08:10 +0100
commitafc883e252f6e158323e55892525fd4f7cb15bcc (patch)
tree3d68bea83aa44037c9e42ba0bac6050db456a232 /lib/chef/resource/openssl_x509_certificate.rb
parentf5f618321ff524cfe5c8cafdf3bdaca55485cd9b (diff)
downloadchef-afc883e252f6e158323e55892525fd4f7cb15bcc.tar.gz
Add the capability to automatically renew a certificate with x509_certificate resource
Signed-off-by: Julien Huon <julien@huon.email>
Diffstat (limited to 'lib/chef/resource/openssl_x509_certificate.rb')
-rw-r--r--lib/chef/resource/openssl_x509_certificate.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/resource/openssl_x509_certificate.rb b/lib/chef/resource/openssl_x509_certificate.rb
index 20cf998239..354c8c0dab 100644
--- a/lib/chef/resource/openssl_x509_certificate.rb
+++ b/lib/chef/resource/openssl_x509_certificate.rb
@@ -109,13 +109,17 @@ class Chef
property :ca_key_pass, String,
description: "The passphrase for CA private key's passphrase."
+ property :renew_before_expiry, Integer,
+ description: "The number of days before the expiry. The certificate will be automaticaly renewed when the value is reached.",
+ default: 5
+
action :create do
description "Generate a certificate"
- unless ::File.exist? new_resource.path
+ if cert_need_renewall?(new_resource.path, new_resource.renew_before_expiry)
converge_by("Create #{@new_resource}") do
file new_resource.path do
- action :create_if_missing
+ action :create
owner new_resource.owner unless new_resource.owner.nil?
group new_resource.group unless new_resource.group.nil?
mode new_resource.mode unless new_resource.mode.nil?