10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [18.1.0](https://github.com/theforeman/puppet-foreman_proxy/tree/18.1.0) (2021-04-30)

[Full Changelog](https://github.com/theforeman/puppet-foreman_proxy/compare/18.0.0...18.1.0)

**Implemented enhancements:**

- Support Ubuntu 20.04 [\#669](https://github.com/theforeman/puppet-foreman_proxy/pull/669) ([ekohl](https://github.com/ekohl))
- Allow puppet-puppet \< 16.0.0 [\#665](https://github.com/theforeman/puppet-foreman_proxy/pull/665) ([wbclark](https://github.com/wbclark))
- don't manage runner repo on Debian [\#664](https://github.com/theforeman/puppet-foreman_proxy/pull/664) ([evgeni](https://github.com/evgeni))

## [18.0.0](https://github.com/theforeman/puppet-foreman_proxy/tree/18.0.0) (2021-04-27)

[Full Changelog](https://github.com/theforeman/puppet-foreman_proxy/compare/17.1.1...18.0.0)
Expand Down
9 changes: 1 addition & 8 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @summary The default parameters for the foreman proxy
# @api private
class foreman_proxy::params inherits foreman_proxy::globals {

$tftp_root = lookup('tftp::root')
$lower_fqdn = downcase($facts['networking']['fqdn'])

case $facts['os']['family'] {
Expand All @@ -25,7 +25,6 @@
$keyfile = '/etc/rndc.key'
$nsupdate = 'bind-utils'

$tftp_root = '/var/lib/tftpboot'
if versioncmp($facts['os']['release']['major'], '7') <= 0 {
$tftp_syslinux_filenames = [
'/usr/share/syslinux/chain.c32',
Expand Down Expand Up @@ -63,11 +62,6 @@
$keyfile = '/etc/bind/rndc.key'
$nsupdate = 'dnsutils'

if $facts['os']['name'] == 'Ubuntu' {
$tftp_root = '/var/lib/tftpboot'
} else {
$tftp_root = '/srv/tftp'
}
$tftp_syslinux_filenames = [
'/usr/lib/PXELINUX/pxelinux.0',
'/usr/lib/syslinux/memdisk',
Expand Down Expand Up @@ -99,7 +93,6 @@
$keyfile = '/usr/local/etc/namedb/rndc.key'
$nsupdate = 'bind-tools'

$tftp_root = '/tftpboot'
$tftp_syslinux_filenames = [
'/usr/local/share/syslinux/bios/core/pxelinux.0',
'/usr/local/share/syslinux/bios/memdisk/memdisk',
Expand Down
3 changes: 3 additions & 0 deletions manifests/plugin/ansible.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#
# $callback:: The callback plugin to configure in ansible.cfg
#
# $runner_package_name:: The name of the ansible-runner package to install
#
class foreman_proxy::plugin::ansible (
Boolean $enabled = $foreman_proxy::plugin::ansible::params::enabled,
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::plugin::ansible::params::listen_on,
Expand All @@ -44,6 +46,7 @@
Boolean $install_runner = $foreman_proxy::plugin::ansible::params::install_runner,
Boolean $manage_runner_repo = $foreman_proxy::plugin::ansible::params::manage_runner_repo,
String $callback = $foreman_proxy::plugin::ansible::params::callback,
String $runner_package_name = $foreman_proxy::plugin::ansible::params::runner_package_name,
) inherits foreman_proxy::plugin::ansible::params {
$foreman_url = $foreman_proxy::foreman_base_url
$foreman_ssl_cert = pick($foreman_proxy::foreman_ssl_cert, $foreman_proxy::ssl_cert)
Expand Down
13 changes: 11 additions & 2 deletions manifests/plugin/ansible/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@
$roles_path = ['/etc/ansible/roles', '/usr/share/ansible/roles']
$ssh_args = '-o ProxyCommand=none -C -o ControlMaster=auto -o ControlPersist=60s'
$install_runner = true
$manage_runner_repo = true
case $facts['os']['family'] {
'RedHat': {
$callback = 'theforeman.foreman.foreman'
$manage_runner_repo = true
$runner_package_name = 'ansible-runner'
}
'Debian': {
$callback = 'foreman'
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '20.04') >= 0) {
$callback = 'theforeman.foreman.foreman'
} else {
$callback = 'foreman'
}
$manage_runner_repo = true
$runner_package_name = 'python3-ansible-runner'
}
default: {
$callback = 'foreman'
$manage_runner_repo = false
$runner_package_name = 'ansible-runner'
}
}
}
13 changes: 2 additions & 11 deletions manifests/plugin/ansible/runner.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,15 @@
#
class foreman_proxy::plugin::ansible::runner(
Boolean $manage_runner_repo = $foreman_proxy::plugin::ansible::manage_runner_repo,
String $package_name = 'ansible-runner',
String $package_name = $foreman_proxy::plugin::ansible::runner_package_name,
) {

if $manage_runner_repo {
case $facts['os']['family'] {
'Debian': {
include apt
apt::source { 'ansible-runner':
repos => 'main',
location => 'https://releases.ansible.com/ansible-runner/deb',
key => {
id => 'B7196EFF934FBC94FBCDF40DD430849D3DD29021',
server => 'keyserver.ubuntu.com',
},
include => {
src => false,
},
before => Package[$package_name],
ensure => absent,
}
}
'RedHat': {
Expand Down
9 changes: 5 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "theforeman-foreman_proxy",
"version": "18.0.0",
"version": "18.1.0",
"author": "theforeman",
"summary": "Foreman Smart Proxy configuration",
"license": "GPL-3.0+",
Expand Down Expand Up @@ -32,11 +32,11 @@
},
{
"name": "theforeman/puppet",
"version_requirement": ">= 10.0.0 < 15.0.0"
"version_requirement": ">= 10.0.0 < 16.0.0"
},
{
"name": "theforeman/tftp",
"version_requirement": ">= 1.3.0 < 7.0.0"
"version_requirement": ">= 3.0.0 < 7.0.0"
},
{
"name": "puppetlabs/stdlib",
Expand Down Expand Up @@ -87,7 +87,8 @@
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"18.04"
"18.04",
"20.04"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion spec/acceptance/ansible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

it_behaves_like 'the default foreman proxy application'

describe package('ansible-runner') do
package_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'python3-ansible-runner' : 'ansible-runner'
describe package(package_name) do
it { is_expected.to be_installed }
end
end
14 changes: 13 additions & 1 deletion spec/acceptance/netboot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@

include_examples 'the example', 'tftp.pp'

root = fact('os.name') == 'Debian' ? '/srv/tftp' : '/var/lib/tftpboot'
root = case host_inventory['facter']['os']['name']
when 'Debian'
'/srv/tftp'
when 'Ubuntu'
if host_inventory['facter']['os']['release']['major'].to_f >= 20.04
'/srv/tftp'
else
'/var/lib/tftpboot'
end
else
'/var/lib/tftpboot'
end

describe file("#{root}/grub2/boot") do
it { should be_symlink }
Expand All @@ -18,6 +29,7 @@

describe command("echo get /grub2/grub.cfg /tmp/downloaded_file | tftp #{fact('fqdn')}") do
its(:exit_status) { should eq 0 }
its(:stdout) { should_not contain('Error code') }
end

describe file('/tmp/downloaded_file') do
Expand Down
18 changes: 7 additions & 11 deletions spec/classes/foreman_proxy__plugin__ansible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@

case os
when 'debian-10-x86_64'
it 'should include ansible-runner upstream repo' do
should contain_apt__source('ansible-runner')
.with_location('https://releases.ansible.com/ansible-runner/deb')
.with_repos('main')
.with_key(
'id' => 'B7196EFF934FBC94FBCDF40DD430849D3DD29021',
'server' => 'keyserver.ubuntu.com'
)
.that_comes_before('Package[ansible-runner]')
it 'should cleanup old ansible-runner upstream repo' do
should contain_apt__source('ansible-runner').with_ensure('absent')
end
it { should contain_package('python3-ansible-runner').with_ensure('installed') }
when 'redhat-7-x86_64'
it 'should include ansible-runner upstream repo' do
should contain_yumrepo('ansible-runner')
Expand All @@ -31,9 +25,9 @@
.with_enabled('1')
.that_comes_before('Package[ansible-runner]')
end
it { should contain_package('ansible-runner').with_ensure('installed') }
end

it { should contain_package('ansible-runner').with_ensure('installed') }

it 'should configure ansible.yml' do
should contain_file('/etc/foreman-proxy/settings.d/ansible.yml').
Expand Down Expand Up @@ -78,10 +72,11 @@
case os
when 'debian-10-x86_64'
it { should_not contain_apt__source('ansible-runner') }
it { should contain_package('python3-ansible-runner').with_ensure('installed') }
when 'redhat-7-x86_64'
it { should_not contain_yumrepo('ansible-runner') }
it { should contain_package('ansible-runner').with_ensure('installed') }
end
it { should contain_package('ansible-runner').with_ensure('installed') }

it 'should configure ansible.yml' do
should contain_file('/etc/foreman-proxy/settings.d/ansible.yml').
Expand Down Expand Up @@ -120,6 +115,7 @@
should_not contain_apt__source('ansible-runner')
should_not contain_yumrepo('ansible-runner')
should_not contain_package('ansible-runner')
should_not contain_package('python3-ansible-runner')
end
end
end
Expand Down
15 changes: 9 additions & 6 deletions spec/classes/foreman_proxy__plugin__discovery_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
context "on #{os}" do
let(:facts) { facts }
let(:pre_condition) { 'include foreman_proxy' }

case facts[:operatingsystem]
let(:tftproot) do
case facts[:operatingsystem]
when 'Debian'
tftproot = '/srv/tftp'
when 'FreeBSD'
tftproot = '/tftpboot'
'/srv/tftp'
when 'FreeBSD', 'DragonFly'
'/tftpboot'
when 'Ubuntu'
facts[:operatingsystemmajrelease] == '18.04' ? '/var/lib/tftpboot' : '/srv/tftp'
else
tftproot = '/var/lib/tftpboot'
'/var/lib/tftpboot'
end
end

describe 'without paramaters' do
Expand Down
11 changes: 4 additions & 7 deletions spec/classes/foreman_proxy__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@
end

let(:tftp_root) do
case facts[:osfamily]
case facts[:operatingsystem]
when 'Debian'
case facts[:operatingsystem]
when 'Ubuntu'
'/var/lib/tftpboot'
else
'/srv/tftp'
end
'/srv/tftp'
when 'FreeBSD', 'DragonFly'
'/tftpboot'
when 'Ubuntu'
facts[:operatingsystemmajrelease] == '18.04' ? '/var/lib/tftpboot' : '/srv/tftp'
else
'/var/lib/tftpboot'
end
Expand Down
6 changes: 5 additions & 1 deletion spec/classes/foreman_proxy__tftp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

case facts[:osfamily]
when 'Debian'
tftp_root = facts[:operatingsystem] == 'Ubuntu' ? '/var/lib/tftpboot' : '/srv/tftp'
tftp_root = if facts[:operatingsystem] == 'Ubuntu'
facts[:operatingsystemmajrelease] == '18.04' ? '/var/lib/tftpboot' : '/srv/tftp'
else
'/srv/tftp'
end
names = {
'/usr/lib/PXELINUX/pxelinux.0' => "#{tftp_root}/pxelinux.0",
'/usr/lib/syslinux/memdisk' => "#{tftp_root}/memdisk",
Expand Down