Skip to content

Commit

Permalink
spec_helper_acceptance.rb: Switch to Vox Pupuli defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Feb 7, 2024
1 parent f88f571 commit 8156885
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 165 deletions.
236 changes: 118 additions & 118 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,130 +2,130 @@

describe 'icingaweb2 class:' do
describe 'icingaweb2 with defaults' do
let(:pp) do
<<-MANIFEST
case $facts['os']['family'] {
'redhat': {
if $facts['os']['name'] == 'centos' and Integer($facts['os']['release']['major']) < 8 {
package { 'centos-release-scl': }
$php_globals = {
php_version => 'rh-php71',
rhscl_mode => 'rhscl',
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-MANIFEST
case $facts['os']['family'] {
'redhat': {
if $facts['os']['name'] == 'centos' and Integer($facts['os']['release']['major']) < 8 {
package { 'centos-release-scl': }
$php_globals = {
php_version => 'rh-php71',
rhscl_mode => 'rhscl',
}
} else {
$php_globals = {}
}
} else {
$php_globals = {}
}
$php_extensions = {
mbstring => { ini_prefix => '20-' },
json => { ini_prefix => '20-' },
ldap => { ini_prefix => '20-' },
gd => { ini_prefix => '20-' },
xml => { ini_prefix => '20-' },
intl => { ini_prefix => '20-' },
mysqlnd => { ini_prefix => '20-' },
pgsql => { ini_prefix => '20-' },
}
$web_conf_user = 'apache'
} # RedHat
'debian': {
$php_globals = {}
$php_extensions = {
mbstring => {},
json => {},
ldap => {},
gd => {},
xml => {},
intl => {},
mysql => {},
pgsql => {},
$php_extensions = {
mbstring => { ini_prefix => '20-' },
json => { ini_prefix => '20-' },
ldap => { ini_prefix => '20-' },
gd => { ini_prefix => '20-' },
xml => { ini_prefix => '20-' },
intl => { ini_prefix => '20-' },
mysqlnd => { ini_prefix => '20-' },
pgsql => { ini_prefix => '20-' },
}
$web_conf_user = 'apache'
} # RedHat
'debian': {
$php_globals = {}
$php_extensions = {
mbstring => {},
json => {},
ldap => {},
gd => {},
xml => {},
intl => {},
mysql => {},
pgsql => {},
}
$web_conf_user = 'www-data'
} # Debian
default: {
fail("'Your operatingsystem ${::operatingsystem} is not supported.'")
}
$web_conf_user = 'www-data'
} # Debian
}
default: {
fail("'Your operatingsystem ${::operatingsystem} is not supported.'")
#
# PHP
#
class { '::php::globals':
* => $php_globals,
}
class { '::php':
ensure => installed,
manage_repos => false,
apache_config => false,
fpm => true,
extensions => $php_extensions,
dev => false,
composer => false,
pear => false,
phpunit => false,
require => Class['::php::globals'],
}
}
#
# PHP
#
class { '::php::globals':
* => $php_globals,
}
class { '::php':
ensure => installed,
manage_repos => false,
apache_config => false,
fpm => true,
extensions => $php_extensions,
dev => false,
composer => false,
pear => false,
phpunit => false,
require => Class['::php::globals'],
}
#
# Apache
#
class { '::apache':
default_mods => false,
default_vhost => false,
mpm_module => 'worker',
}
apache::listen { '80': }
include ::apache::mod::alias
include ::apache::mod::status
include ::apache::mod::dir
include ::apache::mod::env
include ::apache::mod::rewrite
include ::apache::mod::proxy
include ::apache::mod::proxy_fcgi
apache::custom_config { 'icingaweb2':
ensure => present,
source => 'puppet:///modules/icingaweb2/examples/apache2/for-mod_proxy_fcgi.conf',
verify_config => false,
priority => false,
}
#
# Icinga Web 2
#
include ::mysql::server
mysql::db { 'icingaweb2':
user => 'icingaweb2',
password => 'icingaweb2',
host => 'localhost',
grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'],
before => Class['icingaweb2'],
}
Package['icingaweb2']
-> Class['apache']
class { 'icingaweb2':
manage_repos => true,
conf_user => $web_conf_user,
db_type => 'mysql',
db_host => 'localhost',
db_port => 3306,
db_username => 'icingaweb2',
db_password => 'icingaweb2',
import_schema => true,
}
MANIFEST
end
it_behaves_like 'a idempotent resource'
#
# Apache
#
class { '::apache':
default_mods => false,
default_vhost => false,
mpm_module => 'worker',
}
apache::listen { '80': }
include ::apache::mod::alias
include ::apache::mod::status
include ::apache::mod::dir
include ::apache::mod::env
include ::apache::mod::rewrite
include ::apache::mod::proxy
include ::apache::mod::proxy_fcgi
apache::custom_config { 'icingaweb2':
ensure => present,
source => 'puppet:///modules/icingaweb2/examples/apache2/for-mod_proxy_fcgi.conf',
verify_config => false,
priority => false,
}
#
# Icinga Web 2
#
include ::mysql::server
mysql::db { 'icingaweb2':
user => 'icingaweb2',
password => 'icingaweb2',
host => 'localhost',
grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'],
before => Class['icingaweb2'],
}
Package['icingaweb2']
-> Class['apache']
class { 'icingaweb2':
manage_repos => true,
conf_user => $web_conf_user,
db_type => 'mysql',
db_host => 'localhost',
db_port => 3306,
db_username => 'icingaweb2',
db_password => 'icingaweb2',
import_schema => true,
}
MANIFEST
end
end

describe package('icingaweb2') do
it { is_expected.to be_installed }

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - AlmaLinux 9

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Rocky 9

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - AlmaLinux 9

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Distro Puppet - Debian 12

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - CentOS 9

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - CentOS 9

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Rocky 9

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Ubuntu 20.04

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Ubuntu 20.04

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Debian 10

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed

Check failure on line 131 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Debian 10

icingaweb2 class: icingaweb2 with defaults Package "icingaweb2" is expected to be installed Failure/Error: it { is_expected.to be_installed } expected Package "icingaweb2" to be installed
Expand Down
56 changes: 9 additions & 47 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,50 +1,12 @@
require 'beaker-rspec'
require 'beaker/puppet_install_helper'
# frozen_string_literal: true

# Install Puppet on all hosts
install_puppet_agent_on(hosts, puppet_collection: 'puppet5')
require 'voxpupuli/acceptance/spec_helper_acceptance'

RSpec.configure do |c|
module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

c.formatter = :documentation

c.before :suite do
# Install module to all hosts
hosts.each do |host|
install_dev_puppet_module_on(host, source: module_root, module_name: 'icingaweb2',
target_module_path: '/etc/puppetlabs/code/modules')

# Install dependencies
on(host, puppet('module', 'install', 'puppetlabs-stdlib'))
on(host, puppet('module', 'install', 'puppetlabs-concat'))
on(host, puppet('module', 'install', 'puppetlabs-vcsrepo'))

# Install additional modules
on(host, puppet('module', 'install', 'puppetlabs-mysql'))
on(host, puppet('module', 'install', 'puppetlabs-postgresql'))
on(host, puppet('module', 'install', 'puppetlabs-apache'))
on(host, puppet('module', 'install', 'puppet-php'))

if fact('osfamily') == 'Debian'
on(host, puppet('module', 'install', 'puppetlabs-apt'))
end

if fact('osfamily') == 'Suse'
on(host, puppet('module', 'install', 'puppet-zypprepo'))
end

# Add more setup code as needed
end
end
end

shared_examples 'a idempotent resource' do
it 'applies with no errors' do
apply_manifest(pp, catch_failures: true)
end

it 'applies a second time without changes', :skip_pup_5016 do
apply_manifest(pp, catch_changes: true)
end
configure_beaker do |host|
install_puppet_module_via_pmt_on(host, 'puppetlabs-mysql')
install_puppet_module_via_pmt_on(host, 'puppetlabs-postgresql')
install_puppet_module_via_pmt_on(host, 'puppetlabs-apache')
install_puppet_module_via_pmt_on(host, 'puppet-php')
install_puppet_module_via_pmt_on(host, 'puppetlabs-apt')
install_puppet_module_via_pmt_on(host, 'puppet-zypprepo')
end

0 comments on commit 8156885

Please sign in to comment.