-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
91 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2022 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
# nebula::profile::client_cert | ||
# | ||
# Put a copy of the certificate this host uses to talk to the | ||
# puppetserver where apache can see it. This way, the host will be able | ||
# to verify its authenticity with anyone that trusts our puppet CA. | ||
# | ||
# @example Including the profile | ||
# include nebula::profile::client_cert | ||
# | ||
# @example Adding the certificate to an apache vhost | ||
# ssl_proxy_machine_cert => $nebula::profile::client_cert::path, | ||
class nebula::profile::client_cert { | ||
$certname = $trusted['certname']; | ||
$path = "/etc/ssl/private/${certname}.pem"; | ||
|
||
concat { $path: | ||
ensure => 'present', | ||
mode => '0600', | ||
owner => 'root', | ||
} | ||
|
||
concat::fragment { "${path} cert": | ||
target => $path, | ||
source => "/etc/puppetlabs/puppet/ssl/certs/${certname}.pem", | ||
order => 1 | ||
} | ||
|
||
concat::fragment { "${path} key": | ||
target => $path, | ||
source => "/etc/puppetlabs/puppet/ssl/private_keys/${certname}.pem", | ||
order => 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2022 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::client_cert' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
|
||
context 'on a host called default.invalid' do | ||
let(:node) { 'default.invalid' } | ||
let(:cert_path) { '/etc/ssl/private/default.invalid.pem' } | ||
let(:puppet_ssl) { '/etc/puppetlabs/puppet/ssl' } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_concat(cert_path) } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} cert").with_target(cert_path) } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} cert").with_source("#{puppet_ssl}/certs/default.invalid.pem") } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} key").with_target(cert_path) } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} key").with_source("#{puppet_ssl}/private_keys/default.invalid.pem") } | ||
end | ||
|
||
context 'on a host called abc' do | ||
let(:node) { 'abc' } | ||
let(:cert_path) { '/etc/ssl/private/abc.pem' } | ||
let(:puppet_ssl) { '/etc/puppetlabs/puppet/ssl' } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_concat(cert_path) } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} cert").with_target(cert_path) } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} cert").with_source("#{puppet_ssl}/certs/abc.pem") } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} key").with_target(cert_path) } | ||
it { is_expected.to contain_concat__fragment("#{cert_path} key").with_source("#{puppet_ssl}/private_keys/abc.pem") } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters