Skip to content

Commit 8156885

Browse files
committed
spec_helper_acceptance.rb: Switch to Vox Pupuli defaults
1 parent f88f571 commit 8156885

File tree

2 files changed

+127
-165
lines changed

2 files changed

+127
-165
lines changed

Diff for: spec/acceptance/class_spec.rb

+118-118
Original file line numberDiff line numberDiff line change
@@ -2,130 +2,130 @@
22

33
describe 'icingaweb2 class:' do
44
describe 'icingaweb2 with defaults' do
5-
let(:pp) do
6-
<<-MANIFEST
7-
case $facts['os']['family'] {
8-
'redhat': {
9-
if $facts['os']['name'] == 'centos' and Integer($facts['os']['release']['major']) < 8 {
10-
package { 'centos-release-scl': }
11-
12-
$php_globals = {
13-
php_version => 'rh-php71',
14-
rhscl_mode => 'rhscl',
5+
it_behaves_like 'an idempotent resource' do
6+
let(:manifest) do
7+
<<-MANIFEST
8+
case $facts['os']['family'] {
9+
'redhat': {
10+
if $facts['os']['name'] == 'centos' and Integer($facts['os']['release']['major']) < 8 {
11+
package { 'centos-release-scl': }
12+
13+
$php_globals = {
14+
php_version => 'rh-php71',
15+
rhscl_mode => 'rhscl',
16+
}
17+
} else {
18+
$php_globals = {}
1519
}
16-
} else {
17-
$php_globals = {}
18-
}
1920
20-
$php_extensions = {
21-
mbstring => { ini_prefix => '20-' },
22-
json => { ini_prefix => '20-' },
23-
ldap => { ini_prefix => '20-' },
24-
gd => { ini_prefix => '20-' },
25-
xml => { ini_prefix => '20-' },
26-
intl => { ini_prefix => '20-' },
27-
mysqlnd => { ini_prefix => '20-' },
28-
pgsql => { ini_prefix => '20-' },
29-
}
30-
$web_conf_user = 'apache'
31-
} # RedHat
32-
33-
'debian': {
34-
$php_globals = {}
35-
$php_extensions = {
36-
mbstring => {},
37-
json => {},
38-
ldap => {},
39-
gd => {},
40-
xml => {},
41-
intl => {},
42-
mysql => {},
43-
pgsql => {},
21+
$php_extensions = {
22+
mbstring => { ini_prefix => '20-' },
23+
json => { ini_prefix => '20-' },
24+
ldap => { ini_prefix => '20-' },
25+
gd => { ini_prefix => '20-' },
26+
xml => { ini_prefix => '20-' },
27+
intl => { ini_prefix => '20-' },
28+
mysqlnd => { ini_prefix => '20-' },
29+
pgsql => { ini_prefix => '20-' },
30+
}
31+
$web_conf_user = 'apache'
32+
} # RedHat
33+
34+
'debian': {
35+
$php_globals = {}
36+
$php_extensions = {
37+
mbstring => {},
38+
json => {},
39+
ldap => {},
40+
gd => {},
41+
xml => {},
42+
intl => {},
43+
mysql => {},
44+
pgsql => {},
45+
}
46+
$web_conf_user = 'www-data'
47+
} # Debian
48+
49+
default: {
50+
fail("'Your operatingsystem ${::operatingsystem} is not supported.'")
4451
}
45-
$web_conf_user = 'www-data'
46-
} # Debian
52+
}
4753
48-
default: {
49-
fail("'Your operatingsystem ${::operatingsystem} is not supported.'")
54+
#
55+
# PHP
56+
#
57+
class { '::php::globals':
58+
* => $php_globals,
59+
}
60+
61+
class { '::php':
62+
ensure => installed,
63+
manage_repos => false,
64+
apache_config => false,
65+
fpm => true,
66+
extensions => $php_extensions,
67+
dev => false,
68+
composer => false,
69+
pear => false,
70+
phpunit => false,
71+
require => Class['::php::globals'],
5072
}
51-
}
52-
53-
#
54-
# PHP
55-
#
56-
class { '::php::globals':
57-
* => $php_globals,
58-
}
59-
60-
class { '::php':
61-
ensure => installed,
62-
manage_repos => false,
63-
apache_config => false,
64-
fpm => true,
65-
extensions => $php_extensions,
66-
dev => false,
67-
composer => false,
68-
pear => false,
69-
phpunit => false,
70-
require => Class['::php::globals'],
71-
}
72-
73-
#
74-
# Apache
75-
#
76-
class { '::apache':
77-
default_mods => false,
78-
default_vhost => false,
79-
mpm_module => 'worker',
80-
}
81-
82-
apache::listen { '80': }
83-
84-
include ::apache::mod::alias
85-
include ::apache::mod::status
86-
include ::apache::mod::dir
87-
include ::apache::mod::env
88-
include ::apache::mod::rewrite
89-
include ::apache::mod::proxy
90-
include ::apache::mod::proxy_fcgi
91-
92-
apache::custom_config { 'icingaweb2':
93-
ensure => present,
94-
source => 'puppet:///modules/icingaweb2/examples/apache2/for-mod_proxy_fcgi.conf',
95-
verify_config => false,
96-
priority => false,
97-
}
98-
99-
#
100-
# Icinga Web 2
101-
#
102-
include ::mysql::server
103-
104-
mysql::db { 'icingaweb2':
105-
user => 'icingaweb2',
106-
password => 'icingaweb2',
107-
host => 'localhost',
108-
grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'],
109-
before => Class['icingaweb2'],
110-
}
111-
112-
Package['icingaweb2']
113-
-> Class['apache']
114-
115-
class { 'icingaweb2':
116-
manage_repos => true,
117-
conf_user => $web_conf_user,
118-
db_type => 'mysql',
119-
db_host => 'localhost',
120-
db_port => 3306,
121-
db_username => 'icingaweb2',
122-
db_password => 'icingaweb2',
123-
import_schema => true,
124-
}
125-
MANIFEST
126-
end
12773
128-
it_behaves_like 'a idempotent resource'
74+
#
75+
# Apache
76+
#
77+
class { '::apache':
78+
default_mods => false,
79+
default_vhost => false,
80+
mpm_module => 'worker',
81+
}
82+
83+
apache::listen { '80': }
84+
85+
include ::apache::mod::alias
86+
include ::apache::mod::status
87+
include ::apache::mod::dir
88+
include ::apache::mod::env
89+
include ::apache::mod::rewrite
90+
include ::apache::mod::proxy
91+
include ::apache::mod::proxy_fcgi
92+
93+
apache::custom_config { 'icingaweb2':
94+
ensure => present,
95+
source => 'puppet:///modules/icingaweb2/examples/apache2/for-mod_proxy_fcgi.conf',
96+
verify_config => false,
97+
priority => false,
98+
}
99+
100+
#
101+
# Icinga Web 2
102+
#
103+
include ::mysql::server
104+
105+
mysql::db { 'icingaweb2':
106+
user => 'icingaweb2',
107+
password => 'icingaweb2',
108+
host => 'localhost',
109+
grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'],
110+
before => Class['icingaweb2'],
111+
}
112+
113+
Package['icingaweb2']
114+
-> Class['apache']
115+
116+
class { 'icingaweb2':
117+
manage_repos => true,
118+
conf_user => $web_conf_user,
119+
db_type => 'mysql',
120+
db_host => 'localhost',
121+
db_port => 3306,
122+
db_username => 'icingaweb2',
123+
db_password => 'icingaweb2',
124+
import_schema => true,
125+
}
126+
MANIFEST
127+
end
128+
end
129129

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

Diff for: spec/spec_helper_acceptance.rb

+9-47
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,12 @@
1-
require 'beaker-rspec'
2-
require 'beaker/puppet_install_helper'
1+
# frozen_string_literal: true
32

4-
# Install Puppet on all hosts
5-
install_puppet_agent_on(hosts, puppet_collection: 'puppet5')
3+
require 'voxpupuli/acceptance/spec_helper_acceptance'
64

7-
RSpec.configure do |c|
8-
module_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
9-
10-
c.formatter = :documentation
11-
12-
c.before :suite do
13-
# Install module to all hosts
14-
hosts.each do |host|
15-
install_dev_puppet_module_on(host, source: module_root, module_name: 'icingaweb2',
16-
target_module_path: '/etc/puppetlabs/code/modules')
17-
18-
# Install dependencies
19-
on(host, puppet('module', 'install', 'puppetlabs-stdlib'))
20-
on(host, puppet('module', 'install', 'puppetlabs-concat'))
21-
on(host, puppet('module', 'install', 'puppetlabs-vcsrepo'))
22-
23-
# Install additional modules
24-
on(host, puppet('module', 'install', 'puppetlabs-mysql'))
25-
on(host, puppet('module', 'install', 'puppetlabs-postgresql'))
26-
on(host, puppet('module', 'install', 'puppetlabs-apache'))
27-
on(host, puppet('module', 'install', 'puppet-php'))
28-
29-
if fact('osfamily') == 'Debian'
30-
on(host, puppet('module', 'install', 'puppetlabs-apt'))
31-
end
32-
33-
if fact('osfamily') == 'Suse'
34-
on(host, puppet('module', 'install', 'puppet-zypprepo'))
35-
end
36-
37-
# Add more setup code as needed
38-
end
39-
end
40-
end
41-
42-
shared_examples 'a idempotent resource' do
43-
it 'applies with no errors' do
44-
apply_manifest(pp, catch_failures: true)
45-
end
46-
47-
it 'applies a second time without changes', :skip_pup_5016 do
48-
apply_manifest(pp, catch_changes: true)
49-
end
5+
configure_beaker do |host|
6+
install_puppet_module_via_pmt_on(host, 'puppetlabs-mysql')
7+
install_puppet_module_via_pmt_on(host, 'puppetlabs-postgresql')
8+
install_puppet_module_via_pmt_on(host, 'puppetlabs-apache')
9+
install_puppet_module_via_pmt_on(host, 'puppet-php')
10+
install_puppet_module_via_pmt_on(host, 'puppetlabs-apt')
11+
install_puppet_module_via_pmt_on(host, 'puppet-zypprepo')
5012
end

0 commit comments

Comments
 (0)