Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Puppet 8 support #19

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 7.0.0 < 8.0.0"
"version_requirement": ">= 7.0.0 < 9.0.0"
}
],
"operatingsystem_support": [
Expand Down
4 changes: 3 additions & 1 deletion spec/acceptance/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
end

specify do
expect(file('/etc/motd')).to have_attributes(content: /Foreman project/)
evgeni marked this conversation as resolved.
Show resolved Hide resolved
expect(file('/etc/motd')).to be_file
.and(have_attributes(content: /Foreman project/))
.and(have_attributes(content: /FQDN:\s+#{host_inventory['fqdn']}/))
end
end
34 changes: 22 additions & 12 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
require 'spec_helper'

describe 'motd' do
context 'default parameters' do
it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_file('/etc/motd')
.with_ensure('file')
.with_content(/property of the Foreman project/)
end
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }

describe 'with default parameters' do
it { is_expected.to compile.with_all_deps }

context 'with ensure absent parameters' do
let(:params) { {ensure: 'absent'} }
it 'should contain a valid /etc/motd' do
is_expected.to contain_file('/etc/motd')
.with_ensure('file')
.with_content(/property of the Foreman project/)
.with_content(/FQDN:\s+#{facts['fqdn']}/)
.with_content(/Kernel:\s+#{facts['kernelrelease']}/)
.with_content(/Memory:\s#{facts['memorysize']}/)
end
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/motd').with_ensure('absent') }
describe 'with ensure absent parameters' do
let(:params) { {ensure: 'absent'} }

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/motd').with_ensure('absent') }
end
end
end
end
12 changes: 5 additions & 7 deletions templates/motd.erb
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and maybe this file should become EPP, but I was lazy

Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ LOG OFF IMMEDIATELY if you do not agree to the conditions stated in this
warning.
*******************************************************************************

<%= @operatingsystem %> <%= @operatingsystemrelease %> <%= @architecture %>
<%= @facts['os']['name'] %> <%= @facts['os']['release']['full'] %> <%= @facts['os']['architecture'] %>

FQDN: <%= @fqdn %> (<%= @ipaddress %>)
<% if has_variable?("processor0") then -%>
Processor: <%= @processorcount %>x <%= @processor0 %>
<% end -%>
Kernel: <%= @kernelrelease %>
Memory: <%= @memorysize %>
FQDN: <%= @facts['networking']['fqdn'] %> (<%= @facts['networking']['ipaddress'] %>)
Processor: <%= @facts['processors']['count'] %>x <%= @facts['processors']['models'][0] %>
Kernel: <%= @facts['kernelrelease'] %>
Memory: <%= @facts['memory']['system']['total'] %>

<% if has_variable?("owner") then -%>
Owner: <%= @owner -%>
Expand Down