rspec-system-foreman 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.nodeset.yml +20 -0
- data/.prefabs.yml +80 -0
- data/.rvmrc +52 -0
- data/Gemfile +16 -0
- data/LICENSE +17 -0
- data/README.md +11 -0
- data/Rakefile +6 -0
- data/lib/rspec-system-foreman.rb +4 -0
- data/lib/rspec-system-foreman/helpers.rb +37 -0
- data/lib/rspec-system-foreman/helpers/foreman_install.rb +56 -0
- data/lib/rspec-system-foreman/helpers/foreman_installer_install.rb +65 -0
- data/rspec-system-foreman.gemspec +21 -0
- data/spec/spec_helper_system.rb +7 -0
- data/spec/system/install_spec.rb +112 -0
- data/spec/system/installer_spec.rb +96 -0
- metadata +97 -0
data/.gitignore
ADDED
data/.nodeset.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
default_set: 'centos-64-x64'
|
3
|
+
sets:
|
4
|
+
'centos-64-x64':
|
5
|
+
nodes:
|
6
|
+
'main.vm':
|
7
|
+
prefab: 'centos-64-x64'
|
8
|
+
'ubuntu-server-1204-x64':
|
9
|
+
nodes:
|
10
|
+
'main.vm':
|
11
|
+
prefab: 'ubuntu-server-12042-x64'
|
12
|
+
'debian-60-x64':
|
13
|
+
nodes:
|
14
|
+
'main.vm':
|
15
|
+
prefab: 'debian-607-x64'
|
16
|
+
'debian-70-x64':
|
17
|
+
nodes:
|
18
|
+
'main.vm':
|
19
|
+
prefab: 'debian-70-x64'
|
20
|
+
|
data/.prefabs.yml
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
'centos-64-x64':
|
3
|
+
facts:
|
4
|
+
kernelrelease: "2.6.32-358.el6.x86_64"
|
5
|
+
operatingsystem: CentOS
|
6
|
+
kernelmajversion: "2.6"
|
7
|
+
architecture: x86_64
|
8
|
+
facterversion: "1.6.18"
|
9
|
+
kernelversion: "2.6.32"
|
10
|
+
operatingsystemrelease: "6.4"
|
11
|
+
osfamily: RedHat
|
12
|
+
kernel: Linux
|
13
|
+
rubyversion: "1.8.7"
|
14
|
+
provider_specifics:
|
15
|
+
vagrant:
|
16
|
+
box: 'centos-64-x64'
|
17
|
+
box_url: 'http://radon.usersys.redhat.com/templates/boxes/centos-64-x64.box'
|
18
|
+
'ubuntu-server-12042-x64':
|
19
|
+
facts:
|
20
|
+
kernel: Linux
|
21
|
+
architecture: amd64
|
22
|
+
operatingsystem: Ubuntu
|
23
|
+
lsbdistid: Ubuntu
|
24
|
+
facterversion: "1.6.17"
|
25
|
+
kernelmajversion: "3.2"
|
26
|
+
kernelrelease: "3.2.0-29-generic"
|
27
|
+
kernelversion: "3.2.0"
|
28
|
+
lsbdistcodename: precise
|
29
|
+
lsbdistdescription: "Ubuntu 12.04.1 LTS"
|
30
|
+
lsbdistrelease: "12.04"
|
31
|
+
lsbmajdistrelease: "12"
|
32
|
+
operatingsystemrelease: "12.04"
|
33
|
+
osfamily: Debian
|
34
|
+
rubyversion: "1.9.2"
|
35
|
+
provider_specifics:
|
36
|
+
vagrant:
|
37
|
+
box: 'ubuntu-server-12042-x64'
|
38
|
+
box_url: 'http://radon.usersys.redhat.com/templates/boxes/ubuntu-server-12042-x64.box'
|
39
|
+
'debian-70-x64':
|
40
|
+
facts:
|
41
|
+
architecture: amd64
|
42
|
+
kernel: Linux
|
43
|
+
operatingsystem: Debian
|
44
|
+
lsbdistid: Debian
|
45
|
+
facterversion: "1.6.18"
|
46
|
+
kernelmajversion: "3.2"
|
47
|
+
kernelrelease: "3.2.0-4-amd64"
|
48
|
+
kernelversion: "3.2.0"
|
49
|
+
lsbdistcodename: wheezy
|
50
|
+
lsbdistdescription: "Debian GNU/Linux 7.0 (wheezy)"
|
51
|
+
lsbdistrelease: "7.0"
|
52
|
+
lsbmajdistrelease: "7"
|
53
|
+
operatingsystemrelease: "7.0"
|
54
|
+
osfamily: Debian
|
55
|
+
rubyversion: "1.9.3"
|
56
|
+
provider_specifics:
|
57
|
+
vagrant:
|
58
|
+
box: 'debian-70-x64'
|
59
|
+
box_url: 'http://radon.usersys.redhat.com/templates/boxes/debian-70-x64.box'
|
60
|
+
'debian-607-x64':
|
61
|
+
facts:
|
62
|
+
kernel: Linux
|
63
|
+
lsbmajdistrelease: "6"
|
64
|
+
operatingsystemrelease: "6.0.7"
|
65
|
+
kernelrelease: "2.6.32-5-amd64"
|
66
|
+
osfamily: Debian
|
67
|
+
lsbdistrelease: "6.0.7"
|
68
|
+
lsbdistcodename: squeeze
|
69
|
+
lsbdistdescription: "Debian GNU/Linux 6.0.7 (squeeze)"
|
70
|
+
kernelversion: "2.6.32"
|
71
|
+
operatingsystem: Debian
|
72
|
+
kernelmajversion: "2.6"
|
73
|
+
facterversion: "1.6.18"
|
74
|
+
rubyversion: "1.8.7"
|
75
|
+
lsbdistid: Debian
|
76
|
+
architecture: amd64
|
77
|
+
provider_specifics:
|
78
|
+
vagrant:
|
79
|
+
box: 'debian-607-x64'
|
80
|
+
box_url: 'http://radon.usersys.redhat.com/templates/boxes/debian-607-x64.box'
|
data/.rvmrc
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p392@foreman-installer"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.18.11 (latest)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
if [[ $- == *i* ]] # check for interactive shells
|
29
|
+
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
30
|
+
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
|
31
|
+
fi
|
32
|
+
else
|
33
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
34
|
+
rvm --create use "$environment_id" || {
|
35
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
36
|
+
return 1
|
37
|
+
}
|
38
|
+
fi
|
39
|
+
|
40
|
+
# If you use bundler, this might be useful to you:
|
41
|
+
# if [[ -s Gemfile ]] && {
|
42
|
+
# ! builtin command -v bundle >/dev/null ||
|
43
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
44
|
+
# }
|
45
|
+
# then
|
46
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
47
|
+
# gem install bundler
|
48
|
+
# fi
|
49
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
50
|
+
# then
|
51
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
52
|
+
# fi
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
# pending: https://github.com/puppetlabs/rspec-system-puppet/pull/12
|
6
|
+
gem 'rspec-system-puppet', :git => 'git://github.com/domcleal/rspec-system-puppet.git', :branch => 'apply-module-path'
|
7
|
+
|
8
|
+
group :development, :test do
|
9
|
+
gem 'rake'
|
10
|
+
gem 'mocha', :require => 'mocha/api'
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'yard'
|
15
|
+
gem 'redcarpet'
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
rspec-system-foreman - Foreman rspec-system plugin
|
2
|
+
|
3
|
+
Copyright (c) 2013 Dominic Cleal
|
4
|
+
|
5
|
+
Portions copyright (c) 2013 Puppet Labs Inc
|
6
|
+
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
you may not use this file except in compliance with the License.
|
9
|
+
You may obtain a copy of the License at
|
10
|
+
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
See the License for the specific language governing permissions and
|
17
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# rspec-system-foreman
|
2
|
+
|
3
|
+
`rspec-system-foreman` is a plugin for [rspec-system](https://rubygems.org/gems/rspec-system) that can install and configure [Foreman](http://theforeman.org) using the [Foreman installer](https://github.com/theforeman/foreman-installer) Puppet modules.
|
4
|
+
|
5
|
+
Its primary use is testing the Foreman installer and new Foreman packages, but it might also be useful to plugin authors or users wanting a functional Foreman instance to test with.
|
6
|
+
|
7
|
+
The module is based on, and extends, [rspec-system-puppet](https://github.com/puppetlabs/rspec-system-puppet). Check the docs there for good instructions on setting it up.
|
8
|
+
|
9
|
+
## Prefabs
|
10
|
+
|
11
|
+
The prefabs are currently pointing to boxes built for libvirt (KVM), but are intended to be entirely compatible with [the standardised prefabs](https://github.com/puppetlabs/rspec-system#prefabs) used for rspec-system.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rspec-system-foreman'
|
2
|
+
require 'rspec-system-puppet/helpers'
|
3
|
+
require 'rspec-system-foreman/helpers/foreman_install'
|
4
|
+
require 'rspec-system-foreman/helpers/foreman_installer_install'
|
5
|
+
|
6
|
+
# This module contains the methods provide by rspec-system-foreman
|
7
|
+
module RSpecSystemForeman::Helpers
|
8
|
+
include RSpecSystem::Helpers
|
9
|
+
include RSpecSystemPuppet::Helpers
|
10
|
+
|
11
|
+
# Installs the foreman-installer and optionally a repo
|
12
|
+
#
|
13
|
+
# @param opts [Hash] a hash of opts
|
14
|
+
# @option opts [RSpecSystem::Node] :node node to execute DSL on
|
15
|
+
# @option opts [String] :installer_source optional checkout of foreman-installer to use
|
16
|
+
# @option opts [String] :release_url override URL of foreman-release RPM
|
17
|
+
# @option opts [String] :custom_repo override URL of repo to install
|
18
|
+
# @option opts [String] :repo sub-repo to use, default: latest stable release
|
19
|
+
# @return [RSpecSystemForeman::Helpers::ForemanInstallerInstall] results
|
20
|
+
# @yield [result] yields result when called as a block
|
21
|
+
# @yieldparam result [RSpecSystem::Helpers::ForemanInstallerInstall] results
|
22
|
+
def foreman_installer_install(opts = {}, &block)
|
23
|
+
RSpecSystemForeman::Helpers::ForemanInstallerInstall.new(opts, self, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Basic helper to install Foreman with the installer
|
27
|
+
#
|
28
|
+
# @param opts [Hash] a hash of opts
|
29
|
+
# @option opts [RSpecSystem::Node] :node node to execute DSL on
|
30
|
+
# @option opts [Hash] :answers answers file hash, merged with defaults
|
31
|
+
# @return [RSpecSystemForeman::Helpers::ForemanInstall] results
|
32
|
+
# @yield [result] yields result when called as a block
|
33
|
+
# @yieldparam result [RSpecSystem::Helpers::ForemanInstall] results
|
34
|
+
def foreman_install(opts = {}, &block)
|
35
|
+
RSpecSystemForeman::Helpers::ForemanInstall.new(opts, self, &block)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rspec-system'
|
2
|
+
|
3
|
+
module RSpecSystem::Helpers
|
4
|
+
class ForemanInstall < RSpecSystem::Helper
|
5
|
+
name 'foreman_install'
|
6
|
+
|
7
|
+
def execute
|
8
|
+
node = opts[:node]
|
9
|
+
facts = node.facts
|
10
|
+
|
11
|
+
if facts['osfamily'] == 'RedHat' && facts['operatingsystem'] != 'Fedora'
|
12
|
+
log.info "Configuring EPEL"
|
13
|
+
if facts['operatingsystemrelease'] =~ /^6\./
|
14
|
+
shell :c => 'rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm', :n => node
|
15
|
+
else
|
16
|
+
shell :c => 'rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm', :n => node
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
answers = {}
|
21
|
+
shell :c => 'cat /usr/share/foreman-installer/foreman_installer/answers.yaml', :n => node do |r|
|
22
|
+
answers = YAML.load(r.stdout)
|
23
|
+
end
|
24
|
+
# Merge user answers into defaults (can be booleans or hashes)
|
25
|
+
if opts[:answers]
|
26
|
+
opts[:answers].each do |k,v|
|
27
|
+
k = k.to_s
|
28
|
+
v = Hash[v.map {|k,v| [k.to_s, v] }] if v.is_a? Hash
|
29
|
+
if (!v && answers[k]) || (v && !answers[k]) # invert override
|
30
|
+
answers[k] = v
|
31
|
+
elsif v.is_a?(Hash) && !answers[k].is_a?(Hash) # override with options
|
32
|
+
answers[k] = v
|
33
|
+
elsif v.is_a?(Hash) && answers[k].is_a?(Hash) # merge options
|
34
|
+
answers[k].merge! v
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
log.info "Install answers file: #{answers.inspect}"
|
40
|
+
shell :c => 'mkdir /etc/foreman-installer', :n => node
|
41
|
+
file = Tempfile.new('answers')
|
42
|
+
begin
|
43
|
+
file.write(answers.to_yaml)
|
44
|
+
file.close
|
45
|
+
rcp :sp => file.path, :dp => '/etc/foreman-installer/answers.yaml', :d => node
|
46
|
+
ensure
|
47
|
+
file.unlink
|
48
|
+
end
|
49
|
+
|
50
|
+
# Run foreman-installer
|
51
|
+
puppet_apply(:code => 'class { "foreman_installer": }', :n => node, :module_path => '/usr/share/foreman-installer')
|
52
|
+
|
53
|
+
{}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rspec-system'
|
2
|
+
|
3
|
+
module RSpecSystem::Helpers
|
4
|
+
class ForemanInstallerInstall < RSpecSystem::Helper
|
5
|
+
name 'foreman_installer_install'
|
6
|
+
|
7
|
+
def execute
|
8
|
+
node = opts[:node]
|
9
|
+
puppet_install opts
|
10
|
+
|
11
|
+
facts = node.facts
|
12
|
+
|
13
|
+
# Install the installer and optionally the repo
|
14
|
+
if opts[:installer_source]
|
15
|
+
log.info "Copying custom foreman-installer source checkout to /usr/share/foreman-installer"
|
16
|
+
rcp :sp => opts[:installer_source], :dp => '/usr/share/foreman-installer'
|
17
|
+
else
|
18
|
+
if facts['osfamily'] == 'RedHat'
|
19
|
+
if opts[:custom_repo]
|
20
|
+
log.info "Installing custom yum repo from #{opts[:custom_repo]}"
|
21
|
+
file = Tempfile.new('foreman.repo')
|
22
|
+
begin
|
23
|
+
file.write(<<EOS)
|
24
|
+
[foreman]
|
25
|
+
name=Foreman custom repo
|
26
|
+
baseurl=#{opts[:custom_repo]}
|
27
|
+
gpgcheck=0
|
28
|
+
EOS
|
29
|
+
file.close
|
30
|
+
rcp :sp => file.path, :dp => '/etc/yum.repos.d/foreman.repo', :d => node
|
31
|
+
ensure
|
32
|
+
file.unlink
|
33
|
+
end
|
34
|
+
else
|
35
|
+
repo = case facts['operatingsystem']
|
36
|
+
when 'Fedora'
|
37
|
+
"f#{facts['operatingsystemrelease']}"
|
38
|
+
else
|
39
|
+
"el#{facts['operatingsystemrelease'][0]}"
|
40
|
+
end
|
41
|
+
opts[:release_url] ||= "http://yum.theforeman.org/#{opts[:repo] || 'releases/latest'}/#{repo}/#{facts['architecture']}/foreman-release.rpm"
|
42
|
+
log.info "Installing release repo #{opts[:release_url]}"
|
43
|
+
shell :c => "rpm -ivh #{opts[:release_url]}", :n => node
|
44
|
+
end
|
45
|
+
shell :c => 'yum -y install foreman-installer', :n => node
|
46
|
+
elsif facts['osfamily'] == 'Debian'
|
47
|
+
sources = "deb http://deb.theforeman.org/ #{facts['lsbdistcodename']} #{opts[:repo] || 'stable'}"
|
48
|
+
log.info "Configuring sources: #{sources}"
|
49
|
+
file = Tempfile.new('foreman.sources')
|
50
|
+
begin
|
51
|
+
file.write("#{sources}\n")
|
52
|
+
file.close
|
53
|
+
rcp :sp => file.path, :dp => '/etc/apt/sources.list.d/foreman.list', :d => node
|
54
|
+
ensure
|
55
|
+
file.unlink
|
56
|
+
end
|
57
|
+
shell :c => 'wget -q http://deb.theforeman.org/foreman.asc -O- | apt-key add -', :n => node
|
58
|
+
shell :c => 'apt-get update && apt-get -y install foreman-installer', :n => node
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
{}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
# Metadata
|
4
|
+
s.name = "rspec-system-foreman"
|
5
|
+
s.version = "0.1.0"
|
6
|
+
s.authors = ["Dominic Cleal"]
|
7
|
+
s.email = ["dcleal@redhat.com"]
|
8
|
+
s.homepage = "https://github.com/domcleal/rspec-system-foreman"
|
9
|
+
s.summary = "Foreman rspec-system plugin"
|
10
|
+
|
11
|
+
# Manifest
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- {test,spec,features}/*_spec.rb`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.require_paths = ["lib", "resources"]
|
16
|
+
|
17
|
+
# Dependencies
|
18
|
+
s.required_ruby_version = '>= 1.8.7'
|
19
|
+
s.add_runtime_dependency "rspec-system", '~> 2.0'
|
20
|
+
s.add_runtime_dependency "rspec-system-puppet", '~> 2.0'
|
21
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'foreman_install' do
|
4
|
+
before :all do
|
5
|
+
foreman_installer_install
|
6
|
+
end
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
# Cleanup
|
10
|
+
if node.facts['osfamily'] == 'RedHat'
|
11
|
+
shell 'yum --disablerepo=\* --enablerepo=epel\* clean all'
|
12
|
+
shell 'rpm -e epel-release'
|
13
|
+
shell 'rm -rf /etc/foreman-installer'
|
14
|
+
elsif node.facts['osfamily'] == 'Debian'
|
15
|
+
shell 'rm -rf /etc/foreman-installer'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Don't really install
|
19
|
+
RSpecSystemPuppet::Helpers::PuppetApply.any_instance.stub(:execute)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should install EPEL only on EL' do
|
23
|
+
foreman_install
|
24
|
+
if node.facts['osfamily'] == 'RedHat'
|
25
|
+
shell 'rpm -q epel-release' do |r|
|
26
|
+
r.exit_code.should == (node.facts['operatingsystem'] == 'Fedora' ? 1 : 0)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should create answers file' do
|
32
|
+
foreman_install
|
33
|
+
shell 'cat /etc/foreman-installer/answers.yaml' do |r|
|
34
|
+
r.exit_code.should == 0
|
35
|
+
y = YAML.load(r.stdout)
|
36
|
+
y['foreman'].should == true
|
37
|
+
y['foreman_proxy'].should == true
|
38
|
+
y['puppet'].should == true
|
39
|
+
y['puppetmaster'].should == true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'answers option' do
|
44
|
+
it 'should override with false options' do
|
45
|
+
foreman_install :answers => { :foreman_proxy => false }
|
46
|
+
shell 'cat /etc/foreman-installer/answers.yaml' do |r|
|
47
|
+
r.exit_code.should == 0
|
48
|
+
y = YAML.load(r.stdout)
|
49
|
+
y['foreman'].should == true
|
50
|
+
y['foreman_proxy'].should == false
|
51
|
+
y['puppet'].should == true
|
52
|
+
y['puppetmaster'].should == true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should override with true options' do
|
57
|
+
shell :c => 'cp /usr/share/foreman-installer/foreman_installer/answers.yaml /usr/share/foreman-installer/foreman_installer/answers.yaml.bak', :d => node
|
58
|
+
begin
|
59
|
+
file = Tempfile.new 'answers'
|
60
|
+
begin
|
61
|
+
file.write("--- \nforeman: false\n")
|
62
|
+
file.close
|
63
|
+
rcp :sp => file.path, :dp => '/usr/share/foreman-installer/foreman_installer/answers.yaml', :d => node
|
64
|
+
ensure
|
65
|
+
file.unlink
|
66
|
+
end
|
67
|
+
foreman_install :answers => { :foreman => true }
|
68
|
+
shell 'cat /etc/foreman-installer/answers.yaml' do |r|
|
69
|
+
r.exit_code.should == 0
|
70
|
+
y = YAML.load(r.stdout)
|
71
|
+
y['foreman'].should == true
|
72
|
+
end
|
73
|
+
ensure
|
74
|
+
shell :c => 'cp /usr/share/foreman-installer/foreman_installer/answers.yaml.bak /usr/share/foreman-installer/foreman_installer/answers.yaml', :d => node
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should override with hashes' do
|
79
|
+
foreman_install :answers => { :foreman => { :b => 'c' } }
|
80
|
+
shell 'cat /etc/foreman-installer/answers.yaml' do |r|
|
81
|
+
r.exit_code.should == 0
|
82
|
+
y = YAML.load(r.stdout)
|
83
|
+
y['foreman'].should == { 'b' => 'c' }
|
84
|
+
y['foreman_proxy'].should == true
|
85
|
+
y['puppet'].should == true
|
86
|
+
y['puppetmaster'].should == true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should merge hashes' do
|
91
|
+
shell :c => 'cp /usr/share/foreman-installer/foreman_installer/answers.yaml /usr/share/foreman-installer/foreman_installer/answers.yaml.bak', :d => node
|
92
|
+
begin
|
93
|
+
file = Tempfile.new 'answers'
|
94
|
+
begin
|
95
|
+
file.write("--- \nforeman:\n a: b\n b: c\n")
|
96
|
+
file.close
|
97
|
+
rcp :sp => file.path, :dp => '/usr/share/foreman-installer/foreman_installer/answers.yaml', :d => node
|
98
|
+
ensure
|
99
|
+
file.unlink
|
100
|
+
end
|
101
|
+
foreman_install :answers => { :foreman => { :b => 'a', :c => 'c' } }
|
102
|
+
shell 'cat /etc/foreman-installer/answers.yaml' do |r|
|
103
|
+
r.exit_code.should == 0
|
104
|
+
y = YAML.load(r.stdout)
|
105
|
+
y['foreman'].should == { 'a' => 'b', 'b' => 'a', 'c' => 'c' }
|
106
|
+
end
|
107
|
+
ensure
|
108
|
+
shell :c => 'cp /usr/share/foreman-installer/foreman_installer/answers.yaml.bak /usr/share/foreman-installer/foreman_installer/answers.yaml', :d => node
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe 'foreman_installer_install' do
|
4
|
+
before :each do
|
5
|
+
# Cleanup
|
6
|
+
if node.facts['osfamily'] == 'RedHat'
|
7
|
+
shell 'yum --disablerepo=\* --enablerepo=foreman\* clean all'
|
8
|
+
shell 'rpm -e foreman-release'
|
9
|
+
shell 'rpm -e foreman-installer'
|
10
|
+
shell 'rm -rf /etc/yum.repos.d/foreman* /usr/share/foreman-installer'
|
11
|
+
elsif node.facts['osfamily'] == 'Debian'
|
12
|
+
shell 'dpkg -P foreman-installer'
|
13
|
+
shell 'rm -rf /etc/apt/sources.list.d/foreman* /usr/share/foreman-installer'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should install from stable repo by default' do
|
18
|
+
foreman_installer_install
|
19
|
+
if node.facts['osfamily'] == 'RedHat'
|
20
|
+
shell 'cat /etc/yum.repos.d/foreman.repo' do |r|
|
21
|
+
r.stdout =~ %r{/releases/latest}
|
22
|
+
end
|
23
|
+
elsif node.facts['osfamily'] == 'Debian'
|
24
|
+
shell 'cat /etc/apt/sources.list.d/foreman.list' do |r|
|
25
|
+
r.stdout.include? ' stable '
|
26
|
+
end
|
27
|
+
end
|
28
|
+
shell 'test -d /usr/share/foreman-installer/foreman' do |r|
|
29
|
+
r.exit_code.should == 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should install from repo option' do
|
34
|
+
if node.facts['osfamily'] == 'RedHat'
|
35
|
+
foreman_installer_install :repo => 'nightly'
|
36
|
+
shell 'cat /etc/yum.repos.d/foreman.repo' do |r|
|
37
|
+
r.stdout =~ %r{^baseurl=.*/nightly/}
|
38
|
+
end
|
39
|
+
elsif node.facts['osfamily'] == 'Debian'
|
40
|
+
foreman_installer_install :repo => 'stable' # no other repo has foreman-installer
|
41
|
+
shell 'cat /etc/apt/sources.list.d/foreman.list' do |r|
|
42
|
+
r.stdout.include? ' stable '
|
43
|
+
end
|
44
|
+
end
|
45
|
+
shell 'test -d /usr/share/foreman-installer/foreman' do |r|
|
46
|
+
r.exit_code.should == 0
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should install from installer_source option' do
|
51
|
+
Dir.mktmpdir do |source|
|
52
|
+
File.open("#{source}/test", "w") { |f| f.write("test") }
|
53
|
+
foreman_installer_install :installer_source => source
|
54
|
+
if node.facts['osfamily'] == 'RedHat'
|
55
|
+
shell 'test -e /etc/yum.repos.d/foreman.repo' do |r|
|
56
|
+
r.exit_code.should == 1
|
57
|
+
end
|
58
|
+
elsif node.facts['osfamily'] == 'Debian'
|
59
|
+
shell 'test -e /etc/apt/sources.list.d/foreman.list' do |r|
|
60
|
+
r.exit_code.should == 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
shell 'cat /usr/share/foreman-installer/test' do |r|
|
64
|
+
r.stdout.should == 'test'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should configure repo from custom_repo option' do
|
70
|
+
pending 'only supported with yum', :unless => (node.facts['osfamily'] == 'RedHat')
|
71
|
+
repo = 'http://yum.theforeman.org/releases/latest/el6/x86_64/'
|
72
|
+
foreman_installer_install :custom_repo => repo
|
73
|
+
shell 'cat /etc/yum.repos.d/foreman.repo' do |r|
|
74
|
+
r.stdout.should =~ /^name=.*custom/
|
75
|
+
r.stdout.should =~ /^baseurl=#{repo}/
|
76
|
+
r.stdout.should =~ /^gpgcheck=0/
|
77
|
+
end
|
78
|
+
shell 'test -d /usr/share/foreman-installer/foreman' do |r|
|
79
|
+
r.exit_code.should == 0
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should install foreman-release from release_url option' do
|
84
|
+
pending 'only supported with yum', :unless => (node.facts['osfamily'] == 'RedHat')
|
85
|
+
foreman_installer_install :release_url => 'http://yum.theforeman.org/releases/latest/el6/x86_64/foreman-release.rpm'
|
86
|
+
shell 'cat /etc/yum.repos.d/foreman.repo' do |r|
|
87
|
+
r.stdout.should =~ /^name=.*Foreman/i
|
88
|
+
end
|
89
|
+
shell 'rpm -q foreman-release' do |r|
|
90
|
+
r.exit_code.should == 0
|
91
|
+
end
|
92
|
+
shell 'test -d /usr/share/foreman-installer/foreman' do |r|
|
93
|
+
r.exit_code.should == 0
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-system-foreman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dominic Cleal
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec-system
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec-system-puppet
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.0'
|
46
|
+
description:
|
47
|
+
email:
|
48
|
+
- dcleal@redhat.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .nodeset.yml
|
55
|
+
- .prefabs.yml
|
56
|
+
- .rvmrc
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- lib/rspec-system-foreman.rb
|
62
|
+
- lib/rspec-system-foreman/helpers.rb
|
63
|
+
- lib/rspec-system-foreman/helpers/foreman_install.rb
|
64
|
+
- lib/rspec-system-foreman/helpers/foreman_installer_install.rb
|
65
|
+
- rspec-system-foreman.gemspec
|
66
|
+
- spec/spec_helper_system.rb
|
67
|
+
- spec/system/install_spec.rb
|
68
|
+
- spec/system/installer_spec.rb
|
69
|
+
homepage: https://github.com/domcleal/rspec-system-foreman
|
70
|
+
licenses: []
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
- resources
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.8.7
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.8.25
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Foreman rspec-system plugin
|
94
|
+
test_files:
|
95
|
+
- spec/system/install_spec.rb
|
96
|
+
- spec/system/installer_spec.rb
|
97
|
+
has_rdoc:
|