summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-01 20:11:06 +0000
committerGerrit Code Review <review@openstack.org>2017-06-01 20:11:06 +0000
commitd1a42bef4f65fb15b70bd75e506ab40616e2249a (patch)
tree1477121c390ab4372922d4ed7b58648d12aeb361
parent072fc5fb8800a4bb0180c1584616b57df0166510 (diff)
parentfc640d8c0ebe8ca415fee4ec0a973d6bc55b06b8 (diff)
Merge "SSHD Service extensions" into stable/newton
-rw-r--r--Puppetfile_extras4
-rw-r--r--manifests/profile/base/sshd.pp59
-rw-r--r--releasenotes/notes/sshd-437c531301f458bb.yaml5
-rw-r--r--spec/classes/tripleo_profile_base_sshd_spec.rb76
4 files changed, 144 insertions, 0 deletions
diff --git a/Puppetfile_extras b/Puppetfile_extras
index 42134f0..f6e9d70 100644
--- a/Puppetfile_extras
+++ b/Puppetfile_extras
@@ -36,3 +36,7 @@ mod 'ntp',
36mod 'systemd', 36mod 'systemd',
37 :git => 'https://github.com/camptocamp/puppet-systemd', 37 :git => 'https://github.com/camptocamp/puppet-systemd',
38 :ref => 'master' 38 :ref => 'master'
39
40mod 'ssh',
41 :git => 'https://github.com/saz/puppet-ssh',
42 :ref => 'v3.0.1'
diff --git a/manifests/profile/base/sshd.pp b/manifests/profile/base/sshd.pp
new file mode 100644
index 0000000..f43089c
--- /dev/null
+++ b/manifests/profile/base/sshd.pp
@@ -0,0 +1,59 @@
1# Copyright 2016 Red Hat, Inc.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15#
16# == Class: tripleo::profile::base::sshd
17#
18# SSH composable service for TripleO
19#
20# === Parameters
21#
22# [*bannertext*]
23# The text used within /etc/issue and /etc/issue.net
24# Defaults to hiera('BannerText')
25#
26# [*motd*]
27# The text used within SSH Banner
28# Defaults to hiera('MOTD')
29#
30class tripleo::profile::base::sshd (
31 $bannertext = hiera('BannerText', undef),
32 $motd = hiera('MOTD', undef),
33) {
34
35 include ::ssh
36
37 if $bannertext {
38 $filelist = [ '/etc/issue', '/etc/issue.net', ]
39 file { $filelist:
40 ensure => file,
41 backup => false,
42 content => $bannertext,
43 owner => 'root',
44 group => 'root',
45 mode => '0644'
46 }
47 }
48
49 if $motd {
50 file { '/etc/motd':
51 ensure => file,
52 backup => false,
53 content => $motd,
54 owner => 'root',
55 group => 'root',
56 mode => '0644'
57 }
58 }
59}
diff --git a/releasenotes/notes/sshd-437c531301f458bb.yaml b/releasenotes/notes/sshd-437c531301f458bb.yaml
new file mode 100644
index 0000000..5997289
--- /dev/null
+++ b/releasenotes/notes/sshd-437c531301f458bb.yaml
@@ -0,0 +1,5 @@
1---
2features:
3 - Added /etc/issue & /etc/issue.net parameters
4 - Added MOTD banner parameters
5 - Added external module saz-ssh to allow management of sshd_config
diff --git a/spec/classes/tripleo_profile_base_sshd_spec.rb b/spec/classes/tripleo_profile_base_sshd_spec.rb
new file mode 100644
index 0000000..c611fe9
--- /dev/null
+++ b/spec/classes/tripleo_profile_base_sshd_spec.rb
@@ -0,0 +1,76 @@
1# Copyright 2017 Red Hat, Inc.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15#
16# Unit tests for tripleo::profile::base::sshd
17#
18
19require 'spec_helper'
20
21describe 'tripleo::profile::base::sshd' do
22
23 shared_examples_for 'tripleo::profile::base::sshd' do
24
25 context 'it should do nothing' do
26 it do
27 is_expected.to contain_class('ssh')
28 is_expected.to_not contain_file('/etc/issue')
29 is_expected.to_not contain_file('/etc/issue.net')
30 is_expected.to_not contain_file('/etc/motd')
31 end
32 end
33
34 context 'with issue and issue.net configured' do
35 let(:params) {{ :bannertext => 'foo' }}
36 it do
37 is_expected.to contain_file('/etc/issue').with({
38 'content' => 'foo',
39 'owner' => 'root',
40 'group' => 'root',
41 'mode' => '0644',
42 })
43 is_expected.to contain_file('/etc/issue.net').with({
44 'content' => 'foo',
45 'owner' => 'root',
46 'group' => 'root',
47 'mode' => '0644',
48 })
49 is_expected.to_not contain_file('/etc/motd')
50 end
51 end
52
53 context 'with motd configured' do
54 let(:params) {{ :motd => 'foo' }}
55 it do
56 is_expected.to contain_file('/etc/motd').with({
57 'content' => 'foo',
58 'owner' => 'root',
59 'group' => 'root',
60 'mode' => '0644',
61 })
62 is_expected.to_not contain_file('/etc/issue')
63 is_expected.to_not contain_file('/etc/issue.net')
64 end
65 end
66 end
67
68 on_supported_os.each do |os, facts|
69 context "on #{os}" do
70 let (:facts) {
71 facts
72 }
73 it_behaves_like 'tripleo::profile::base::sshd'
74 end
75 end
76end