82 changes: 12 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,21 @@
---
name: CI

on:
pull_request:
schedule:
- cron: '4 4 * * *'

jobs:
setup_matrix:
if: github.event_name != 'schedule' || github.repository_owner == 'theforeman'
name: 'Setup Test Matrix'
runs-on: ubuntu-latest
outputs:
beaker_setfiles: ${{ steps.get_outputs.outputs.beaker_setfiles }}
puppet_major_versions: ${{ steps.get_outputs.outputs.puppet_major_versions }}
puppet_unit_test_matrix: ${{ steps.get_outputs.outputs.puppet_unit_test_matrix }}
env:
BUNDLE_WITHOUT: development:system_tests:release
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Run rake check
run: bundle exec rake check
- name: Run rake validate
run: bundle exec rake validate
- name: Run rake lint
run: bundle exec rake lint
- name: Setup Test Matrix
id: get_outputs
run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false

unit:
needs: setup_matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}}
env:
BUNDLE_WITHOUT: development:system_tests:release
PUPPET_VERSION: "${{ matrix.puppet }}.0"
name: Unit / Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }})
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake parallel_spec
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true

acceptance:
needs: setup_matrix
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: development:test:release
strategy:
fail-fast: false
matrix:
setfile: ${{fromJson(needs.setup_matrix.outputs.beaker_setfiles)}}
puppet: ${{fromJson(needs.setup_matrix.outputs.puppet_major_versions)}}
name: Acceptance / ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }}
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Run tests
run: bundle exec rake beaker
env:
BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
BEAKER_setfile: ${{ matrix.setfile.value }}
jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
with:
pidfile_workaround: 'false'
rubocop: false
cache-version: '1'
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [8.2.0](https://github.com/theforeman/puppet-dhcp/tree/8.2.0) (2022-08-04)

[Full Changelog](https://github.com/theforeman/puppet-dhcp/compare/8.1.0...8.2.0)

**Implemented enhancements:**

- Update to voxpupuli-test 5 [\#214](https://github.com/theforeman/puppet-dhcp/pull/214) ([ekohl](https://github.com/ekohl))
- Remove nameserver sorting for dhcp subnet configurations [\#213](https://github.com/theforeman/puppet-dhcp/pull/213) ([jan-win1993](https://github.com/jan-win1993))
- Support CentOS 9 [\#209](https://github.com/theforeman/puppet-dhcp/pull/209) ([ekohl](https://github.com/ekohl))

## [8.1.0](https://github.com/theforeman/puppet-dhcp/tree/8.1.0) (2022-02-03)

[Full Changelog](https://github.com/theforeman/puppet-dhcp/compare/8.0.0...8.1.0)
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

source 'https://rubygems.org'

gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : '>= 5.5', groups: ['development', 'test']
gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '>= 5.5', groups: ['development', 'test']
gem 'rake'

gem 'kafo_module_lint', {"groups"=>["test"]}
Expand All @@ -13,9 +13,9 @@ gem 'puppet-lint-param-docs', '>= 1.3.0', {"groups"=>["test"]}
gem 'puppet-lint-spaceship_operator_without_tag-check', {"groups"=>["test"]}
gem 'puppet-lint-strict_indent-check', {"groups"=>["test"]}
gem 'puppet-lint-undef_in_function-check', {"groups"=>["test"]}
gem 'voxpupuli-test', '~> 1.4', {"groups"=>["test"]}
gem 'voxpupuli-test', '~> 5.0', {"groups"=>["test"]}
gem 'github_changelog_generator', '>= 1.15.0', {"groups"=>["development"]}
gem 'puppet_metadata', '~> 0.3'
gem 'puppet_metadata', '~> 1.3'
gem 'puppet-blacksmith', '>= 6.0.0', {"groups"=>["development"]}
gem 'voxpupuli-acceptance', '~> 1.0', {"groups"=>["system_tests"]}
gem 'puppetlabs_spec_helper', {"groups"=>["system_tests"]}
Expand Down
2 changes: 1 addition & 1 deletion examples/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
peer_address => '10.1.1.20',
}

dhcp::pool{ 'example.com':
dhcp::pool { 'example.com':
network => '10.1.1.0',
mask => '255.255.255.0',
range => '10.1.1.100 10.1.1.200',
Expand Down
1 change: 0 additions & 1 deletion manifests/disable.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
hasstatus => true,
require => Package[$packagename],
}

}
1 change: 0 additions & 1 deletion manifests/failover.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
Variant[Integer[0], String] $load_balance = 3,
Optional[String] $omapi_key = undef,
) {

include dhcp

concat::fragment { 'dhcp.conf+10_failover.dhcp':
Expand Down
1 change: 0 additions & 1 deletion manifests/host.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
Optional[String] $raw_append = undef,
Optional[String] $raw_prepend = undef,
) {

$host = $name

concat::fragment { "dhcp.hosts+10_${name}.hosts":
Expand Down
10 changes: 6 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Manage an ISC DHCP server
#
# @param option_static_route
# When enabled it sets the options rfc3442-classless-static-routes and ms-classless-static-routes
class dhcp (
Array[String] $dnsdomain = $dhcp::params::dnsdomain,
Array[String] $nameservers = [],
Expand Down Expand Up @@ -28,7 +31,7 @@
Optional[Stdlib::Filemode] $conf_dir_mode = $dhcp::params::conf_dir_mode,
String $packagename = $dhcp::params::packagename,
String $servicename = $dhcp::params::servicename,
$option_static_route = undef,
Boolean $option_static_route = false,
Variant[Array[String], Optional[String]] $options = undef,
Boolean $authoritative = false,
String $dhcp_root_user = 'root',
Expand All @@ -44,12 +47,11 @@
Variant[Array[String], Optional[String]] $includes = undef,
String $config_comment = 'dhcpd.conf',
) inherits dhcp::params {

# In case people set interface instead of interfaces work around
# that. If they set both, use interfaces and the user is a unwise
# and deserves what they get.
if $interface != 'NOTSET' and $interfaces == undef {
$dhcp_interfaces = [ $interface ]
$dhcp_interfaces = [$interface]
} elsif $interface == 'NOTSET' and $interfaces == undef {
fail ("You need to set \$interfaces in ${module_name}")
} else {
Expand Down Expand Up @@ -88,7 +90,7 @@
# Only debian and ubuntu have this style of defaults for startup.
case $facts['os']['family'] {
'Debian': {
file{ '/etc/default/isc-dhcp-server':
file { '/etc/default/isc-dhcp-server':
ensure => file,
owner => 'root',
group => 'root',
Expand Down
1 change: 0 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Default parameters
# @api private
class dhcp::params {

if fact('networking.domain') {
$dnsdomain = [$facts['networking']['domain']]
} else {
Expand Down
1 change: 0 additions & 1 deletion manifests/pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Optional[String] $raw_append = undef,
Optional[String] $raw_prepend = undef,
) {

dhcp::subnet { $name:
network => $network,
mask => $mask,
Expand Down
5 changes: 3 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "theforeman-dhcp",
"version": "8.1.0",
"version": "8.2.0",
"author": "theforeman",
"summary": "Manage the ISC DHCP daemon",
"license": "Apache-2.0",
Expand Down Expand Up @@ -46,7 +46,8 @@
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7",
"8"
"8",
"9"
]
},
{
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 @@ -2,6 +2,7 @@

describe 'Simple installation' do
interface = 'eth0'
config_file = fact('osfamily') == 'Archlinux' ? '/etc/dhcpd.conf' : '/etc/dhcp/dhcpd.conf'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
Expand All @@ -27,7 +28,8 @@ class { 'dhcp':

it_behaves_like 'a DHCP server'

describe file("/etc/dhcp/dhcpd.conf") do
describe file(config_file) do
it { is_expected.to be_file }
its(:content) { should_not match %r{option domain-name-servers } }
end

Expand Down
7 changes: 5 additions & 2 deletions spec/acceptance/nameservers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe 'with empty nameservers list' do
interface = 'eth0'
config_file = fact('osfamily') == 'Archlinux' ? '/etc/dhcpd.conf' : '/etc/dhcp/dhcpd.conf'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
Expand All @@ -23,7 +24,8 @@ class { 'dhcp':

it_behaves_like 'a DHCP server'

describe file("/etc/dhcp/dhcpd.conf") do
describe file(config_file) do
it { is_expected.to be_file }
its(:content) { should_not match %r{option domain-name-servers } }
end

Expand All @@ -40,6 +42,7 @@ class { 'dhcp':

describe 'with a non-empty nameservers list' do
interface = 'eth0'
config_file = fact('osfamily') == 'Archlinux' ? '/etc/dhcpd.conf' : '/etc/dhcp/dhcpd.conf'

it_behaves_like 'an idempotent resource' do
let(:manifest) do
Expand All @@ -61,7 +64,7 @@ class { 'dhcp':

it_behaves_like 'a DHCP server'

describe file("/etc/dhcp/dhcpd.conf") do
describe file(config_file) do
its(:content) { should match %r{option domain-name-servers 8.8.8.8, 8.8.4.4;} }
end

Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

require 'voxpupuli/test/spec_helper'

add_mocked_facts!

def get_content(subject, title)
is_expected.to contain_file(title)
content = subject.resource('file', title).send(:parameters)[:content]
Expand Down
2 changes: 2 additions & 0 deletions spec/support/acceptance/examples.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
shared_examples 'a DHCP server' do
service_name = case fact('osfamily')
when 'Archlinux'
'dhcpd4'
when 'Debian'
'isc-dhcp-server'
else
Expand Down
2 changes: 1 addition & 1 deletion templates/dhcpd.subnet.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ subnet <%= @network %> netmask <%= @mask %> {
<%= @parameters %>;
<% end -%>
<% if @nameservers and @nameservers.is_a? Array -%>
option domain-name-servers <%= @nameservers.sort.join(', ') %>;
option domain-name-servers <%= @nameservers.join(', ') %>;
<% elsif @nameservers -%>
option domain-name-servers <%= @nameservers %>;
<% end -%>
Expand Down