Commit ae4746a4 authored by m.pausch's avatar m.pausch
Browse files

By popular demand

parent 00f9c742
#
# Cookbook:: sys
# Library:: Helpers::X509
#
# Copyright:: 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
#
# Authors:
# Matthias Pausch (m.pausch@gsi.de)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This code is an adjustment of https://github.com/sous-chefs/firewall
#
module Sys
module Helpers
module X509
def certificate_file_content(new_resource)
cert_item = data_bag_item(new_resource.data_bag, new_resource.bag_item)
cert_item['file-content']
end
def key_vault_item(new_resource)
new_resource.vault_item || new_resource.bag_item
end
def key_file_content(new_resource)
key_item = chef_vault_item(new_resource.chef_vault,
key_vault_item(new_resource))
key_item['file-content']
end
end
end
end
......@@ -25,7 +25,19 @@
if Gem::Requirement.new('>= 12.15').satisfied_by?(Gem::Version.new(Chef::VERSION))
action_class do
include Sys::Helpers::X509
def certificate_file_content
cert_item = data_bag_item(new_resource.data_bag, new_resource.bag_item)
cert_item['file-content']
end
def key_vault_item
new_resource.vault_item || new_resource.bag_item
end
def key_file_content
key_item = chef_vault_item(new_resource.chef_vault, key_vault_item)
key_item['file-content']
end
end
provides :x509_certificate, os: 'linux'
......@@ -55,7 +67,7 @@ if Gem::Requirement.new('>= 12.15').satisfied_by?(Gem::Version.new(Chef::VERSION
begin
file new_resource.certificate_path do
content certificate_file_content(new_resource)
content certificate_file_content
owner 'root'
group 'root'
mode '0644'
......@@ -66,7 +78,7 @@ if Gem::Requirement.new('>= 12.15').satisfied_by?(Gem::Version.new(Chef::VERSION
begin
file new_resource.key_path do
content key_file_content(new_resource)
content key_file_content
owner 'root'
group 'ssl-cert'
mode '0640'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment