summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-01-12 11:39:45 -0800
committerTim Smith <tsmith@chef.io>2018-01-12 11:39:45 -0800
commit4949304de73689367bfb88061262561977c521d5 (patch)
tree1231fed8aeaeb63149d00bc9c91ba5ebd900fa45
parent0e0dec68c0651c0411a37c07cf68d3f677c086f6 (diff)
downloadchef-4949304de73689367bfb88061262561977c521d5.tar.gz
Allow file to handle the OS specific values
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/openssl_dhparam.rb10
-rw-r--r--lib/chef/resource/openssl_rsa_private_key.rb10
-rw-r--r--lib/chef/resource/openssl_rsa_public_key.rb10
3 files changed, 18 insertions, 12 deletions
diff --git a/lib/chef/resource/openssl_dhparam.rb b/lib/chef/resource/openssl_dhparam.rb
index 6c261a5a8f..cec27d21bd 100644
--- a/lib/chef/resource/openssl_dhparam.rb
+++ b/lib/chef/resource/openssl_dhparam.rb
@@ -23,6 +23,8 @@ class Chef
# If a valid dhparam.pem file is found at the specified location, no new
# file will be created. If a file is found at the specified location but it
# is not a valid dhparam file, it will be overwritten.
+ #
+ # @since 14.0
class OpensslDhparam < Chef::Resource
require "chef/mixin/openssl"
include Chef::Mixin::OpenSSL
@@ -32,8 +34,8 @@ class Chef
property :path, String, name_property: true
property :key_length, equal_to: [1024, 2048, 4096, 8192], default: 2048
property :generator, equal_to: [2, 5], default: 2
- property :owner, String, default: lazy { node["platform"] == "windows" ? "Adminstrator" : "root" }
- property :group, String, default: lazy { node["root_group"] }
+ property :owner, [String, nil]
+ property :group, [String, nil]
property :mode, [Integer, String], default: "0640"
action :create do
@@ -43,8 +45,8 @@ class Chef
declare_resource(:file, new_resource.path) do
action :create
- owner new_resource.owner
- group new_resource.group
+ owner new_resource.owner unless new_resource.owner.nil?
+ group new_resource.group unless new_resource.group.nil?
mode new_resource.mode
sensitive true
content dhparam_content
diff --git a/lib/chef/resource/openssl_rsa_private_key.rb b/lib/chef/resource/openssl_rsa_private_key.rb
index 738dfd6aa5..32c394846b 100644
--- a/lib/chef/resource/openssl_rsa_private_key.rb
+++ b/lib/chef/resource/openssl_rsa_private_key.rb
@@ -24,6 +24,8 @@ class Chef
# will be created. If the RSA key file cannot be opened, either because it
# does not exist or because the password to the RSA key file does not match
# the password in the recipe, it will be overwritten.
+ #
+ # @since 14.0
class OpensslRsaPrivateKey < Chef::Resource
require "chef/mixin/openssl"
include Chef::Mixin::OpenSSL
@@ -36,8 +38,8 @@ class Chef
property :key_length, equal_to: [1024, 2048, 4096, 8192], default: 2048
property :key_pass, String
property :key_cipher, String, default: "des3", equal_to: OpenSSL::Cipher.ciphers
- property :owner, String, default: lazy { node["platform"] == "windows" ? "Adminstrator" : "root" }
- property :group, String, default: lazy { node["root_group"] }
+ property :owner, [String, nil]
+ property :group, [String, nil]
property :mode, [Integer, String], default: "0600"
property :force, [true, false], default: false
@@ -54,8 +56,8 @@ class Chef
declare_resource(:file, new_resource.path) do
action :create
- owner new_resource.owner
- group new_resource.group
+ owner new_resource.owner unless new_resource.owner.nil?
+ group new_resource.group unless new_resource.group.nil?
mode new_resource.mode
sensitive true
content rsa_key_content
diff --git a/lib/chef/resource/openssl_rsa_public_key.rb b/lib/chef/resource/openssl_rsa_public_key.rb
index 4cffe53f6d..602b48065e 100644
--- a/lib/chef/resource/openssl_rsa_public_key.rb
+++ b/lib/chef/resource/openssl_rsa_public_key.rb
@@ -20,6 +20,8 @@ require "chef/resource"
class Chef
class Resource
# A resource for generating rsa public key files given a rsa private key.
+ #
+ # @since 14.0
class OpensslRsaPublicKey < Chef::Resource
require "chef/mixin/openssl"
include Chef::Mixin::OpenSSL
@@ -30,8 +32,8 @@ class Chef
property :private_key_path, String
property :private_key_content, String
property :private_key_pass, String
- property :owner, String, default: lazy { node["platform"] == "windows" ? "Adminstrator" : "root" }
- property :group, String, default: lazy { node["root_group"] }
+ property :owner, [String, nil]
+ property :group, [String, nil]
property :mode, [Integer, String], default: "0640"
action :create do
@@ -43,8 +45,8 @@ class Chef
declare_resource(:file, new_resource.path) do
action :create
- owner new_resource.owner
- group new_resource.group
+ owner new_resource.owner unless new_resource.owner.nil?
+ group new_resource.group unless new_resource.group.nil?
mode new_resource.mode
content rsa_key_content
end