kitchen-puppet 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +27 -27
- data/kitchen-puppet.gemspec +28 -27
- data/lib/kitchen-puppet/version.rb +7 -7
- data/lib/kitchen/provisioner/puppet/librarian.rb +78 -78
- data/lib/kitchen/provisioner/puppet_agent.rb +384 -384
- data/lib/kitchen/provisioner/puppet_apply.rb +847 -846
- data/lib/kitchen/provisioner/puppet_apply_spec.rb +33 -33
- data/provisioner_options.md +196 -196
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36fd358f7c8da3bc3cd2b237ea8f019073f3dd0d
|
|
4
|
+
data.tar.gz: 7a46cf27a5c6341575abb77973f0e7f48a0df2b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 127466f7d9ce29f275bf2d47f2022b9a31e78bcd7a9f6fb834f6af5f0cf3220f7953655477fda48cd03d84082acc168043a6f95ca157ee07a61a4f650f745ff9
|
|
7
|
+
data.tar.gz: ce52f4bf834f87126cf2e4b7a81c012d0b7a7eec0b85c408821f701b6a01ea5af516d9c61f5447ee7fa6346700ebee80103718ccf18f8d820941a37d2688dc09
|
data/README.md
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# Kitchen Puppet
|
|
2
|
-
|
|
3
|
-
[](http://badge.fury.io/rb/kitchen-puppet)
|
|
4
|
-
[](https://rubygems.org/gems/kitchen-puppet)
|
|
5
|
-
[](https://travis-ci.org/neillturner/kitchen-puppet)
|
|
6
|
-
|
|
7
|
-
# kitchen-puppet
|
|
8
|
-
A Test Kitchen Provisioner for Puppet
|
|
9
|
-
|
|
10
|
-
The providers supports both puppet apply and puppet agent clients
|
|
11
|
-
|
|
12
|
-
The PuppetApply provider works by passing the puppet repository based on attributes in .kitchen.yml & calling puppet apply.
|
|
13
|
-
|
|
14
|
-
The PuppetAgent provider works by passing the puppetmaster and other attributes in .kitchen.yml & calling puppet agent.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
This provider has been tested against the Ubuntu 1204 and Centos 6.5 boxes running in vagrant/virtualbox.
|
|
18
|
-
|
|
19
|
-
## Requirements
|
|
20
|
-
You'll need a driver box without a chef installation so puppet can be installed. Puppet have one at http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box or http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box.
|
|
21
|
-
|
|
22
|
-
For PuppetAgent a server with a puppet master is required that can resolve the hostname ip address of the server. The server must also be able to resolve the hostname ip address of the puppet master.
|
|
23
|
-
|
|
24
|
-
## Installation & Setup
|
|
25
|
-
You'll need the test-kitchen & kitchen-puppet gem's installed in your system, along with kitchen-vagrant or some ther suitable driver for test-kitchen.
|
|
26
|
-
|
|
27
|
-
Please see the Provisioner Options (https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md).
|
|
1
|
+
# Kitchen Puppet
|
|
2
|
+
|
|
3
|
+
[](http://badge.fury.io/rb/kitchen-puppet)
|
|
4
|
+
[](https://rubygems.org/gems/kitchen-puppet)
|
|
5
|
+
[](https://travis-ci.org/neillturner/kitchen-puppet)
|
|
6
|
+
|
|
7
|
+
# kitchen-puppet
|
|
8
|
+
A Test Kitchen Provisioner for Puppet
|
|
9
|
+
|
|
10
|
+
The providers supports both puppet apply and puppet agent clients
|
|
11
|
+
|
|
12
|
+
The PuppetApply provider works by passing the puppet repository based on attributes in .kitchen.yml & calling puppet apply.
|
|
13
|
+
|
|
14
|
+
The PuppetAgent provider works by passing the puppetmaster and other attributes in .kitchen.yml & calling puppet agent.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
This provider has been tested against the Ubuntu 1204 and Centos 6.5 boxes running in vagrant/virtualbox.
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
You'll need a driver box without a chef installation so puppet can be installed. Puppet have one at http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box or http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box.
|
|
21
|
+
|
|
22
|
+
For PuppetAgent a server with a puppet master is required that can resolve the hostname ip address of the server. The server must also be able to resolve the hostname ip address of the puppet master.
|
|
23
|
+
|
|
24
|
+
## Installation & Setup
|
|
25
|
+
You'll need the test-kitchen & kitchen-puppet gem's installed in your system, along with kitchen-vagrant or some ther suitable driver for test-kitchen.
|
|
26
|
+
|
|
27
|
+
Please see the Provisioner Options (https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md).
|
data/kitchen-puppet.gemspec
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
4
|
-
require 'kitchen-puppet/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |s|
|
|
7
|
-
s.name = 'kitchen-puppet'
|
|
8
|
-
s.version = Kitchen::Puppet::VERSION
|
|
9
|
-
s.authors = ['Neill Turner']
|
|
10
|
-
s.email = ['neillwturner@gmail.com']
|
|
11
|
-
s.homepage = 'https://github.com/neillturner/kitchen-puppet'
|
|
12
|
-
s.summary = 'puppet provisioner for test-kitchen'
|
|
13
|
-
candidates = Dir.glob('{lib}/**/*') + ['README.md', 'provisioner_options.md', 'kitchen-puppet.gemspec']
|
|
14
|
-
s.files = candidates.sort
|
|
15
|
-
s.platform = Gem::Platform::RUBY
|
|
16
|
-
s.require_paths = ['lib']
|
|
17
|
-
s.rubyforge_project = '[none]'
|
|
18
|
-
s.description = <<-EOF
|
|
19
|
-
== DESCRIPTION:
|
|
20
|
-
|
|
21
|
-
Puppet Provisioner for Test Kitchen
|
|
22
|
-
|
|
23
|
-
== FEATURES:
|
|
24
|
-
|
|
25
|
-
Supports puppet apply, puppet agent, hiera, hiera-eyaml, custom facts, librarian-puppet, puppet collections (v4)
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
4
|
+
require 'kitchen-puppet/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = 'kitchen-puppet'
|
|
8
|
+
s.version = Kitchen::Puppet::VERSION
|
|
9
|
+
s.authors = ['Neill Turner']
|
|
10
|
+
s.email = ['neillwturner@gmail.com']
|
|
11
|
+
s.homepage = 'https://github.com/neillturner/kitchen-puppet'
|
|
12
|
+
s.summary = 'puppet provisioner for test-kitchen'
|
|
13
|
+
candidates = Dir.glob('{lib}/**/*') + ['README.md', 'provisioner_options.md', 'kitchen-puppet.gemspec']
|
|
14
|
+
s.files = candidates.sort
|
|
15
|
+
s.platform = Gem::Platform::RUBY
|
|
16
|
+
s.require_paths = ['lib']
|
|
17
|
+
s.rubyforge_project = '[none]'
|
|
18
|
+
s.description = <<-EOF
|
|
19
|
+
== DESCRIPTION:
|
|
20
|
+
|
|
21
|
+
Puppet Provisioner for Test Kitchen
|
|
22
|
+
|
|
23
|
+
== FEATURES:
|
|
24
|
+
|
|
25
|
+
Supports puppet apply, puppet agent, hiera, hiera-eyaml, custom facts, librarian-puppet, puppet collections (v4)
|
|
26
|
+
|
|
27
|
+
EOF
|
|
28
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
module Kitchen
|
|
4
|
-
module Puppet
|
|
5
|
-
VERSION = '0.0.
|
|
6
|
-
end
|
|
7
|
-
end
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Kitchen
|
|
4
|
+
module Puppet
|
|
5
|
+
VERSION = '0.0.28'
|
|
6
|
+
end
|
|
7
|
+
end
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>) Neill Turner (<neillwturner@gmail.com>)
|
|
4
|
-
#
|
|
5
|
-
# Copyright (C) 2013, Fletcher Nichol, Neill Turner
|
|
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.
|
|
18
|
-
|
|
19
|
-
require 'kitchen/errors'
|
|
20
|
-
require 'kitchen/logging'
|
|
21
|
-
|
|
22
|
-
module Kitchen
|
|
23
|
-
module Provisioner
|
|
24
|
-
module Puppet
|
|
25
|
-
# Puppet module resolver that uses Librarian-Puppet and a Puppetfile to
|
|
26
|
-
# calculate # dependencies.
|
|
27
|
-
#
|
|
28
|
-
class Librarian
|
|
29
|
-
include Logging
|
|
30
|
-
|
|
31
|
-
def initialize(puppetfile, path, logger = Kitchen.logger)
|
|
32
|
-
@puppetfile = puppetfile
|
|
33
|
-
@path = path
|
|
34
|
-
@logger = logger
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.load!(logger = Kitchen.logger)
|
|
38
|
-
load_librarian!(logger)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def resolve
|
|
42
|
-
version = ::Librarian::Puppet::VERSION
|
|
43
|
-
info("Resolving module dependencies with Librarian-Puppet #{version}...")
|
|
44
|
-
debug("Using Puppetfile from #{puppetfile}")
|
|
45
|
-
|
|
46
|
-
env = ::Librarian::Puppet::Environment.new(
|
|
47
|
-
project_path: File.dirname(puppetfile))
|
|
48
|
-
env.config_db.local['path'] = path
|
|
49
|
-
::Librarian::Action::Resolve.new(env).run
|
|
50
|
-
::Librarian::Action::Install.new(env).run
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
attr_reader :puppetfile, :path, :logger
|
|
54
|
-
|
|
55
|
-
def self.load_librarian!(logger)
|
|
56
|
-
first_load = require 'librarian/puppet'
|
|
57
|
-
require 'librarian/puppet/environment'
|
|
58
|
-
require 'librarian/action/resolve'
|
|
59
|
-
require 'librarian/action/install'
|
|
60
|
-
|
|
61
|
-
version = ::Librarian::Puppet::VERSION
|
|
62
|
-
if first_load
|
|
63
|
-
logger.debug("Librarian-Puppet #{version} library loaded")
|
|
64
|
-
else
|
|
65
|
-
logger.debug("Librarian-Puppet #{version} previously loaded")
|
|
66
|
-
end
|
|
67
|
-
rescue LoadError => e
|
|
68
|
-
logger.fatal("The `librarian-puppet' gem is missing and must be installed" \
|
|
69
|
-
' or cannot be properly activated. Run' \
|
|
70
|
-
' `gem install librarian-puppet` or add the following to your' \
|
|
71
|
-
" Gemfile if you are using Bundler: `gem 'librarian-puppet'`.")
|
|
72
|
-
raise UserError,
|
|
73
|
-
"Could not load or activate Librarian-Puppet (#{e.message})"
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>) Neill Turner (<neillwturner@gmail.com>)
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2013, Fletcher Nichol, Neill Turner
|
|
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.
|
|
18
|
+
|
|
19
|
+
require 'kitchen/errors'
|
|
20
|
+
require 'kitchen/logging'
|
|
21
|
+
|
|
22
|
+
module Kitchen
|
|
23
|
+
module Provisioner
|
|
24
|
+
module Puppet
|
|
25
|
+
# Puppet module resolver that uses Librarian-Puppet and a Puppetfile to
|
|
26
|
+
# calculate # dependencies.
|
|
27
|
+
#
|
|
28
|
+
class Librarian
|
|
29
|
+
include Logging
|
|
30
|
+
|
|
31
|
+
def initialize(puppetfile, path, logger = Kitchen.logger)
|
|
32
|
+
@puppetfile = puppetfile
|
|
33
|
+
@path = path
|
|
34
|
+
@logger = logger
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.load!(logger = Kitchen.logger)
|
|
38
|
+
load_librarian!(logger)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def resolve
|
|
42
|
+
version = ::Librarian::Puppet::VERSION
|
|
43
|
+
info("Resolving module dependencies with Librarian-Puppet #{version}...")
|
|
44
|
+
debug("Using Puppetfile from #{puppetfile}")
|
|
45
|
+
|
|
46
|
+
env = ::Librarian::Puppet::Environment.new(
|
|
47
|
+
project_path: File.dirname(puppetfile))
|
|
48
|
+
env.config_db.local['path'] = path
|
|
49
|
+
::Librarian::Action::Resolve.new(env).run
|
|
50
|
+
::Librarian::Action::Install.new(env).run
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
attr_reader :puppetfile, :path, :logger
|
|
54
|
+
|
|
55
|
+
def self.load_librarian!(logger)
|
|
56
|
+
first_load = require 'librarian/puppet'
|
|
57
|
+
require 'librarian/puppet/environment'
|
|
58
|
+
require 'librarian/action/resolve'
|
|
59
|
+
require 'librarian/action/install'
|
|
60
|
+
|
|
61
|
+
version = ::Librarian::Puppet::VERSION
|
|
62
|
+
if first_load
|
|
63
|
+
logger.debug("Librarian-Puppet #{version} library loaded")
|
|
64
|
+
else
|
|
65
|
+
logger.debug("Librarian-Puppet #{version} previously loaded")
|
|
66
|
+
end
|
|
67
|
+
rescue LoadError => e
|
|
68
|
+
logger.fatal("The `librarian-puppet' gem is missing and must be installed" \
|
|
69
|
+
' or cannot be properly activated. Run' \
|
|
70
|
+
' `gem install librarian-puppet` or add the following to your' \
|
|
71
|
+
" Gemfile if you are using Bundler: `gem 'librarian-puppet'`.")
|
|
72
|
+
raise UserError,
|
|
73
|
+
"Could not load or activate Librarian-Puppet (#{e.message})"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -1,384 +1,384 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Author:: Chris Lundquist (<chris.lundquist@github.com>) Neill Turner (<neillwturner@gmail.com>)
|
|
4
|
-
#
|
|
5
|
-
# Copyright (C) 2013,2014 Chris Lundquist, Neill Turner
|
|
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.
|
|
18
|
-
#
|
|
19
|
-
# See https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md
|
|
20
|
-
# for documentation configuration parameters with puppet_agent provisioner.
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
require 'json'
|
|
24
|
-
require 'kitchen/provisioner/base'
|
|
25
|
-
require 'kitchen/provisioner/puppet/librarian'
|
|
26
|
-
|
|
27
|
-
module Kitchen
|
|
28
|
-
class Busser
|
|
29
|
-
def non_suite_dirs
|
|
30
|
-
%w(data data_bags environments nodes roles puppet)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
module Provisioner
|
|
35
|
-
#
|
|
36
|
-
# Puppet Agent provisioner.
|
|
37
|
-
#
|
|
38
|
-
class PuppetAgent < Base
|
|
39
|
-
attr_accessor :tmp_dir
|
|
40
|
-
|
|
41
|
-
default_config :require_puppet_omnibus, false
|
|
42
|
-
# TODO: use something like https://github.com/fnichol/omnibus-puppet
|
|
43
|
-
default_config :puppet_omnibus_url, nil
|
|
44
|
-
default_config :puppet_omnibus_remote_path, '/opt/puppet'
|
|
45
|
-
default_config :puppet_version, nil
|
|
46
|
-
default_config :require_puppet_repo, true
|
|
47
|
-
default_config :require_chef_for_busser, true
|
|
48
|
-
|
|
49
|
-
default_config :puppet_apt_repo, 'http://apt.puppetlabs.com/puppetlabs-release-precise.deb'
|
|
50
|
-
default_config :puppet_yum_repo, 'https://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm'
|
|
51
|
-
default_config :chef_bootstrap_url, 'https://www.getchef.com/chef/install.sh'
|
|
52
|
-
|
|
53
|
-
default_config :puppet_agent_command, nil
|
|
54
|
-
|
|
55
|
-
default_config :http_proxy, nil
|
|
56
|
-
|
|
57
|
-
default_config :puppet_config_path do |provisioner|
|
|
58
|
-
provisioner.calculate_path('puppet.conf', :file)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
default_config :puppet_debug, false
|
|
62
|
-
default_config :puppet_verbose, false
|
|
63
|
-
default_config :puppet_noop, false
|
|
64
|
-
default_config :puppet_platform, ''
|
|
65
|
-
default_config :update_package_repos, true
|
|
66
|
-
|
|
67
|
-
default_config :custom_facts, {}
|
|
68
|
-
|
|
69
|
-
default_config :puppet_detailed_exitcodes, nil
|
|
70
|
-
default_config :puppet_logdest, nil
|
|
71
|
-
default_config :puppet_masterport, nil
|
|
72
|
-
default_config :puppet_test, false
|
|
73
|
-
default_config :puppet_onetime, true
|
|
74
|
-
default_config :puppet_no_daemonize, true
|
|
75
|
-
default_config :puppet_server, nil # will default to 'puppet'
|
|
76
|
-
default_config :puppet_waitforcert, '0'
|
|
77
|
-
default_config :puppet_certname, nil
|
|
78
|
-
default_config :puppet_digest, nil
|
|
79
|
-
|
|
80
|
-
def calculate_path(path, type = :directory)
|
|
81
|
-
base = config[:test_base_path]
|
|
82
|
-
candidates = []
|
|
83
|
-
candidates << File.join(base, instance.suite.name, 'puppet', path)
|
|
84
|
-
candidates << File.join(base, instance.suite.name, path)
|
|
85
|
-
candidates << File.join(base, path)
|
|
86
|
-
candidates << File.join(Dir.pwd, path)
|
|
87
|
-
|
|
88
|
-
candidates.find do |c|
|
|
89
|
-
type == :directory ? File.directory?(c) : File.file?(c)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
94
|
-
def install_command
|
|
95
|
-
return unless config[:require_puppet_omnibus] || config[:require_puppet_repo]
|
|
96
|
-
if config[:require_puppet_omnibus]
|
|
97
|
-
info('Installing puppet using puppet omnibus')
|
|
98
|
-
if !config[:puppet_version].nil?
|
|
99
|
-
version = "-v #{config[:puppet_version]}"
|
|
100
|
-
else
|
|
101
|
-
version = ''
|
|
102
|
-
end
|
|
103
|
-
<<-INSTALL
|
|
104
|
-
#{Util.shell_helpers}
|
|
105
|
-
|
|
106
|
-
if [ ! -d "#{config[:puppet_omnibus_remote_path]}" ]; then
|
|
107
|
-
echo "-----> Installing Puppet Omnibus"
|
|
108
|
-
do_download #{config[:puppet_omnibus_url]} /tmp/puppet_install.sh
|
|
109
|
-
#{sudo('sh')} /tmp/puppet_install.sh #{version}
|
|
110
|
-
fi
|
|
111
|
-
#{install_busser}
|
|
112
|
-
INSTALL
|
|
113
|
-
else
|
|
114
|
-
case puppet_platform
|
|
115
|
-
when 'debian', 'ubuntu'
|
|
116
|
-
info("Installing puppet on #{puppet_platform}")
|
|
117
|
-
<<-INSTALL
|
|
118
|
-
if [ ! $(which puppet) ]; then
|
|
119
|
-
#{sudo('apt-get')} -y install wget
|
|
120
|
-
#{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
|
|
121
|
-
#{sudo('dpkg')} -i #{puppet_apt_repo_file}
|
|
122
|
-
#{update_packages_debian_cmd}
|
|
123
|
-
#{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
|
|
124
|
-
#{sudo('apt-get')} -y install puppet#{puppet_debian_version}
|
|
125
|
-
fi
|
|
126
|
-
#{install_busser}
|
|
127
|
-
INSTALL
|
|
128
|
-
when 'redhat', 'centos', 'fedora', 'oracle', 'amazon'
|
|
129
|
-
info("Installing puppet on #{puppet_platform}")
|
|
130
|
-
<<-INSTALL
|
|
131
|
-
if [ ! $(which puppet) ]; then
|
|
132
|
-
#{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
|
|
133
|
-
#{update_packages_redhat_cmd}
|
|
134
|
-
#{sudo('yum')} -y install puppet#{puppet_redhat_version}
|
|
135
|
-
fi
|
|
136
|
-
#{install_busser}
|
|
137
|
-
INSTALL
|
|
138
|
-
else
|
|
139
|
-
info('Installing puppet, will try to determine platform os')
|
|
140
|
-
<<-INSTALL
|
|
141
|
-
if [ ! $(which puppet) ]; then
|
|
142
|
-
if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then
|
|
143
|
-
#{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
|
|
144
|
-
#{update_packages_redhat_cmd}
|
|
145
|
-
#{sudo('yum')} -y install puppet#{puppet_redhat_version}
|
|
146
|
-
else
|
|
147
|
-
if [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then
|
|
148
|
-
#{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
|
|
149
|
-
#{update_packages_redhat_cmd}
|
|
150
|
-
#{sudo('yum')} -y install puppet#{puppet_redhat_version}
|
|
151
|
-
else
|
|
152
|
-
#{sudo('apt-get')} -y install wget
|
|
153
|
-
#{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
|
|
154
|
-
#{sudo('dpkg')} -i #{puppet_apt_repo_file}
|
|
155
|
-
#{update_packages_debian_cmd}
|
|
156
|
-
#{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
|
|
157
|
-
#{sudo('apt-get')} -y install puppet#{puppet_debian_version}
|
|
158
|
-
fi
|
|
159
|
-
fi
|
|
160
|
-
fi
|
|
161
|
-
#{install_busser}
|
|
162
|
-
INSTALL
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
167
|
-
|
|
168
|
-
def install_busser
|
|
169
|
-
return unless config[:require_chef_for_busser]
|
|
170
|
-
<<-INSTALL
|
|
171
|
-
#{Util.shell_helpers}
|
|
172
|
-
# install chef omnibus so that busser works as this is needed to run tests :(
|
|
173
|
-
# TODO: work out how to install enough ruby
|
|
174
|
-
# and set busser: { :ruby_bindir => '/usr/bin/ruby' } so that we dont need the
|
|
175
|
-
# whole chef client
|
|
176
|
-
if [ ! -d "/opt/chef" ]
|
|
177
|
-
then
|
|
178
|
-
echo "-----> Installing Chef Omnibus to install busser to run tests"
|
|
179
|
-
do_download #{chef_url} /tmp/install.sh
|
|
180
|
-
#{sudo('sh')} /tmp/install.sh
|
|
181
|
-
fi
|
|
182
|
-
INSTALL
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def init_command
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def create_sandbox
|
|
189
|
-
super
|
|
190
|
-
debug("Creating local sandbox in #{sandbox_path}")
|
|
191
|
-
|
|
192
|
-
yield if block_given?
|
|
193
|
-
|
|
194
|
-
prepare_puppet_config
|
|
195
|
-
info('Finished Preparing files for transfer')
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def cleanup_sandbox
|
|
199
|
-
return if sandbox_path.nil?
|
|
200
|
-
debug("Cleaning up local sandbox in #{sandbox_path}")
|
|
201
|
-
FileUtils.rmtree(sandbox_path)
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def prepare_command
|
|
205
|
-
commands = []
|
|
206
|
-
|
|
207
|
-
if puppet_config
|
|
208
|
-
commands << [
|
|
209
|
-
sudo('cp'),
|
|
210
|
-
File.join(config[:root_path], 'puppet.conf'),
|
|
211
|
-
'/etc/puppet'
|
|
212
|
-
].join(' ')
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
command = commands.join(' && ')
|
|
216
|
-
debug(command)
|
|
217
|
-
command
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def run_command
|
|
221
|
-
if !config[:puppet_agent_command].nil?
|
|
222
|
-
return config[:puppet_agent_command]
|
|
223
|
-
else
|
|
224
|
-
[
|
|
225
|
-
custom_facts,
|
|
226
|
-
sudo_env('puppet'),
|
|
227
|
-
'agent',
|
|
228
|
-
puppet_server_flag,
|
|
229
|
-
"--waitforcert=#{config[:puppet_waitforcert]}",
|
|
230
|
-
puppet_masterport_flag,
|
|
231
|
-
puppet_certname_flag,
|
|
232
|
-
puppet_digest_flag,
|
|
233
|
-
puppet_detailed_exitcodes_flag,
|
|
234
|
-
puppet_logdest_flag,
|
|
235
|
-
puppet_test_flag,
|
|
236
|
-
puppet_onetime_flag,
|
|
237
|
-
puppet_no_daemonize_flag,
|
|
238
|
-
puppet_noop_flag,
|
|
239
|
-
puppet_verbose_flag,
|
|
240
|
-
puppet_debug_flag
|
|
241
|
-
].join(' ')
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
protected
|
|
246
|
-
|
|
247
|
-
def load_needed_dependencies!
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
def puppet_config
|
|
251
|
-
config[:puppet_config_path]
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
def puppet_debian_version
|
|
255
|
-
config[:puppet_version] ? "=#{config[:puppet_version]}" : nil
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
def puppet_redhat_version
|
|
259
|
-
config[:puppet_version] ? "-#{config[:puppet_version]}" : nil
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
def puppet_noop_flag
|
|
263
|
-
config[:puppet_noop] ? '--noop' : nil
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
def puppet_debug_flag
|
|
267
|
-
config[:puppet_debug] ? '-d' : nil
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
def puppet_verbose_flag
|
|
271
|
-
config[:puppet_verbose] ? '-v' : nil
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
def puppet_platform
|
|
275
|
-
config[:puppet_platform].to_s.downcase
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
def update_packages_debian_cmd
|
|
279
|
-
config[:update_package_repos] ? "#{sudo_env('apt-get')} update" : nil
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
def update_packages_redhat_cmd
|
|
283
|
-
config[:update_package_repos] ? "#{sudo_env('yum')} makecache" : nil
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
def sudo_env(pm)
|
|
287
|
-
http_proxy ? "#{sudo('env')} http_proxy=#{http_proxy} #{pm}" : "#{sudo(pm)}"
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
def custom_facts
|
|
291
|
-
return nil if config[:custom_facts].none?
|
|
292
|
-
bash_vars = config[:custom_facts].map { |k, v| "FACTER_#{k}=#{v}" }.join(' ')
|
|
293
|
-
bash_vars = "export #{bash_vars};"
|
|
294
|
-
debug(bash_vars)
|
|
295
|
-
bash_vars
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
def puppet_server_flag
|
|
299
|
-
config[:puppet_server] ? "--server=#{config[:puppet_server]}" : nil
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
def puppet_masterport_flag
|
|
303
|
-
config[:puppet_masterport] ? '--masterport=#{config[:puppet_masterport]}' : nil
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
def puppet_detailed_exitcodes_flag
|
|
307
|
-
config[:puppet_detailed_exitcodes] ? '--detailed-exitcodes' : nil
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
def puppet_logdest_flag
|
|
311
|
-
config[:puppet_logdest] ? "--logdest=#{config[:puppet_logdest]}" : nil
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
def puppet_test_flag
|
|
315
|
-
config[:puppet_test] ? '--test' : nil
|
|
316
|
-
end
|
|
317
|
-
|
|
318
|
-
def puppet_onetime_flag
|
|
319
|
-
config[:puppet_onetime] ? '--onetime' : nil
|
|
320
|
-
end
|
|
321
|
-
|
|
322
|
-
def puppet_no_daemonize_flag
|
|
323
|
-
config[:puppet_no_daemonize] ? '--no-daemonize' : nil
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
def puppet_no_daemonize
|
|
327
|
-
config[:puppet_no_daemonize]
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
def puppet_server
|
|
331
|
-
config[:puppet_server]
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
def puppet_certname_flag
|
|
335
|
-
config[:puppet_certname] ? "--certname=#{config[:puppet_certname]}" : nil
|
|
336
|
-
end
|
|
337
|
-
|
|
338
|
-
def puppet_digest_flag
|
|
339
|
-
config[:puppet_digest] ? "--digest=#{config[:puppet_digest]}" : nil
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
def puppet_apt_repo
|
|
343
|
-
config[:puppet_apt_repo]
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
def puppet_apt_repo_file
|
|
347
|
-
config[:puppet_apt_repo].split('/').last
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
def puppet_yum_repo
|
|
351
|
-
config[:puppet_yum_repo]
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
def proxy_parm
|
|
355
|
-
http_proxy ? "--httpproxy #{URI.parse(http_proxy).host.downcase} --httpport #{URI.parse(http_proxy).port} " : nil
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
def gem_proxy_parm
|
|
359
|
-
http_proxy ? "--http-proxy #{http_proxy}" : nil
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
def wget_proxy_parm
|
|
363
|
-
http_proxy ? "-e use_proxy=yes -e http_proxy=#{http_proxy}" : nil
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
def http_proxy
|
|
367
|
-
config[:http_proxy]
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
def chef_url
|
|
371
|
-
config[:chef_bootstrap_url]
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
def prepare_puppet_config
|
|
375
|
-
return unless puppet_config
|
|
376
|
-
|
|
377
|
-
info('Preparing puppet.conf')
|
|
378
|
-
debug("Using puppet config from #{puppet_config}")
|
|
379
|
-
|
|
380
|
-
FileUtils.cp_r(puppet_config, File.join(sandbox_path, 'puppet.conf'))
|
|
381
|
-
end
|
|
382
|
-
end
|
|
383
|
-
end
|
|
384
|
-
end
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Author:: Chris Lundquist (<chris.lundquist@github.com>) Neill Turner (<neillwturner@gmail.com>)
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2013,2014 Chris Lundquist, Neill Turner
|
|
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.
|
|
18
|
+
#
|
|
19
|
+
# See https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md
|
|
20
|
+
# for documentation configuration parameters with puppet_agent provisioner.
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'json'
|
|
24
|
+
require 'kitchen/provisioner/base'
|
|
25
|
+
require 'kitchen/provisioner/puppet/librarian'
|
|
26
|
+
|
|
27
|
+
module Kitchen
|
|
28
|
+
class Busser
|
|
29
|
+
def non_suite_dirs
|
|
30
|
+
%w(data data_bags environments nodes roles puppet)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module Provisioner
|
|
35
|
+
#
|
|
36
|
+
# Puppet Agent provisioner.
|
|
37
|
+
#
|
|
38
|
+
class PuppetAgent < Base
|
|
39
|
+
attr_accessor :tmp_dir
|
|
40
|
+
|
|
41
|
+
default_config :require_puppet_omnibus, false
|
|
42
|
+
# TODO: use something like https://github.com/fnichol/omnibus-puppet
|
|
43
|
+
default_config :puppet_omnibus_url, nil
|
|
44
|
+
default_config :puppet_omnibus_remote_path, '/opt/puppet'
|
|
45
|
+
default_config :puppet_version, nil
|
|
46
|
+
default_config :require_puppet_repo, true
|
|
47
|
+
default_config :require_chef_for_busser, true
|
|
48
|
+
|
|
49
|
+
default_config :puppet_apt_repo, 'http://apt.puppetlabs.com/puppetlabs-release-precise.deb'
|
|
50
|
+
default_config :puppet_yum_repo, 'https://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm'
|
|
51
|
+
default_config :chef_bootstrap_url, 'https://www.getchef.com/chef/install.sh'
|
|
52
|
+
|
|
53
|
+
default_config :puppet_agent_command, nil
|
|
54
|
+
|
|
55
|
+
default_config :http_proxy, nil
|
|
56
|
+
|
|
57
|
+
default_config :puppet_config_path do |provisioner|
|
|
58
|
+
provisioner.calculate_path('puppet.conf', :file)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
default_config :puppet_debug, false
|
|
62
|
+
default_config :puppet_verbose, false
|
|
63
|
+
default_config :puppet_noop, false
|
|
64
|
+
default_config :puppet_platform, ''
|
|
65
|
+
default_config :update_package_repos, true
|
|
66
|
+
|
|
67
|
+
default_config :custom_facts, {}
|
|
68
|
+
|
|
69
|
+
default_config :puppet_detailed_exitcodes, nil
|
|
70
|
+
default_config :puppet_logdest, nil
|
|
71
|
+
default_config :puppet_masterport, nil
|
|
72
|
+
default_config :puppet_test, false
|
|
73
|
+
default_config :puppet_onetime, true
|
|
74
|
+
default_config :puppet_no_daemonize, true
|
|
75
|
+
default_config :puppet_server, nil # will default to 'puppet'
|
|
76
|
+
default_config :puppet_waitforcert, '0'
|
|
77
|
+
default_config :puppet_certname, nil
|
|
78
|
+
default_config :puppet_digest, nil
|
|
79
|
+
|
|
80
|
+
def calculate_path(path, type = :directory)
|
|
81
|
+
base = config[:test_base_path]
|
|
82
|
+
candidates = []
|
|
83
|
+
candidates << File.join(base, instance.suite.name, 'puppet', path)
|
|
84
|
+
candidates << File.join(base, instance.suite.name, path)
|
|
85
|
+
candidates << File.join(base, path)
|
|
86
|
+
candidates << File.join(Dir.pwd, path)
|
|
87
|
+
|
|
88
|
+
candidates.find do |c|
|
|
89
|
+
type == :directory ? File.directory?(c) : File.file?(c)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
94
|
+
def install_command
|
|
95
|
+
return unless config[:require_puppet_omnibus] || config[:require_puppet_repo]
|
|
96
|
+
if config[:require_puppet_omnibus]
|
|
97
|
+
info('Installing puppet using puppet omnibus')
|
|
98
|
+
if !config[:puppet_version].nil?
|
|
99
|
+
version = "-v #{config[:puppet_version]}"
|
|
100
|
+
else
|
|
101
|
+
version = ''
|
|
102
|
+
end
|
|
103
|
+
<<-INSTALL
|
|
104
|
+
#{Util.shell_helpers}
|
|
105
|
+
|
|
106
|
+
if [ ! -d "#{config[:puppet_omnibus_remote_path]}" ]; then
|
|
107
|
+
echo "-----> Installing Puppet Omnibus"
|
|
108
|
+
do_download #{config[:puppet_omnibus_url]} /tmp/puppet_install.sh
|
|
109
|
+
#{sudo('sh')} /tmp/puppet_install.sh #{version}
|
|
110
|
+
fi
|
|
111
|
+
#{install_busser}
|
|
112
|
+
INSTALL
|
|
113
|
+
else
|
|
114
|
+
case puppet_platform
|
|
115
|
+
when 'debian', 'ubuntu'
|
|
116
|
+
info("Installing puppet on #{puppet_platform}")
|
|
117
|
+
<<-INSTALL
|
|
118
|
+
if [ ! $(which puppet) ]; then
|
|
119
|
+
#{sudo('apt-get')} -y install wget
|
|
120
|
+
#{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
|
|
121
|
+
#{sudo('dpkg')} -i #{puppet_apt_repo_file}
|
|
122
|
+
#{update_packages_debian_cmd}
|
|
123
|
+
#{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
|
|
124
|
+
#{sudo('apt-get')} -y install puppet#{puppet_debian_version}
|
|
125
|
+
fi
|
|
126
|
+
#{install_busser}
|
|
127
|
+
INSTALL
|
|
128
|
+
when 'redhat', 'centos', 'fedora', 'oracle', 'amazon'
|
|
129
|
+
info("Installing puppet on #{puppet_platform}")
|
|
130
|
+
<<-INSTALL
|
|
131
|
+
if [ ! $(which puppet) ]; then
|
|
132
|
+
#{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
|
|
133
|
+
#{update_packages_redhat_cmd}
|
|
134
|
+
#{sudo('yum')} -y install puppet#{puppet_redhat_version}
|
|
135
|
+
fi
|
|
136
|
+
#{install_busser}
|
|
137
|
+
INSTALL
|
|
138
|
+
else
|
|
139
|
+
info('Installing puppet, will try to determine platform os')
|
|
140
|
+
<<-INSTALL
|
|
141
|
+
if [ ! $(which puppet) ]; then
|
|
142
|
+
if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then
|
|
143
|
+
#{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
|
|
144
|
+
#{update_packages_redhat_cmd}
|
|
145
|
+
#{sudo('yum')} -y install puppet#{puppet_redhat_version}
|
|
146
|
+
else
|
|
147
|
+
if [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then
|
|
148
|
+
#{sudo('rpm')} -ivh #{proxy_parm} #{puppet_yum_repo}
|
|
149
|
+
#{update_packages_redhat_cmd}
|
|
150
|
+
#{sudo('yum')} -y install puppet#{puppet_redhat_version}
|
|
151
|
+
else
|
|
152
|
+
#{sudo('apt-get')} -y install wget
|
|
153
|
+
#{sudo('wget')} #{wget_proxy_parm} #{puppet_apt_repo}
|
|
154
|
+
#{sudo('dpkg')} -i #{puppet_apt_repo_file}
|
|
155
|
+
#{update_packages_debian_cmd}
|
|
156
|
+
#{sudo('apt-get')} -y install puppet-common#{puppet_debian_version}
|
|
157
|
+
#{sudo('apt-get')} -y install puppet#{puppet_debian_version}
|
|
158
|
+
fi
|
|
159
|
+
fi
|
|
160
|
+
fi
|
|
161
|
+
#{install_busser}
|
|
162
|
+
INSTALL
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
167
|
+
|
|
168
|
+
def install_busser
|
|
169
|
+
return unless config[:require_chef_for_busser]
|
|
170
|
+
<<-INSTALL
|
|
171
|
+
#{Util.shell_helpers}
|
|
172
|
+
# install chef omnibus so that busser works as this is needed to run tests :(
|
|
173
|
+
# TODO: work out how to install enough ruby
|
|
174
|
+
# and set busser: { :ruby_bindir => '/usr/bin/ruby' } so that we dont need the
|
|
175
|
+
# whole chef client
|
|
176
|
+
if [ ! -d "/opt/chef" ]
|
|
177
|
+
then
|
|
178
|
+
echo "-----> Installing Chef Omnibus to install busser to run tests"
|
|
179
|
+
do_download #{chef_url} /tmp/install.sh
|
|
180
|
+
#{sudo('sh')} /tmp/install.sh
|
|
181
|
+
fi
|
|
182
|
+
INSTALL
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def init_command
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def create_sandbox
|
|
189
|
+
super
|
|
190
|
+
debug("Creating local sandbox in #{sandbox_path}")
|
|
191
|
+
|
|
192
|
+
yield if block_given?
|
|
193
|
+
|
|
194
|
+
prepare_puppet_config
|
|
195
|
+
info('Finished Preparing files for transfer')
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def cleanup_sandbox
|
|
199
|
+
return if sandbox_path.nil?
|
|
200
|
+
debug("Cleaning up local sandbox in #{sandbox_path}")
|
|
201
|
+
FileUtils.rmtree(sandbox_path)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def prepare_command
|
|
205
|
+
commands = []
|
|
206
|
+
|
|
207
|
+
if puppet_config
|
|
208
|
+
commands << [
|
|
209
|
+
sudo('cp'),
|
|
210
|
+
File.join(config[:root_path], 'puppet.conf'),
|
|
211
|
+
'/etc/puppet'
|
|
212
|
+
].join(' ')
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
command = commands.join(' && ')
|
|
216
|
+
debug(command)
|
|
217
|
+
command
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def run_command
|
|
221
|
+
if !config[:puppet_agent_command].nil?
|
|
222
|
+
return config[:puppet_agent_command]
|
|
223
|
+
else
|
|
224
|
+
[
|
|
225
|
+
custom_facts,
|
|
226
|
+
sudo_env('puppet'),
|
|
227
|
+
'agent',
|
|
228
|
+
puppet_server_flag,
|
|
229
|
+
"--waitforcert=#{config[:puppet_waitforcert]}",
|
|
230
|
+
puppet_masterport_flag,
|
|
231
|
+
puppet_certname_flag,
|
|
232
|
+
puppet_digest_flag,
|
|
233
|
+
puppet_detailed_exitcodes_flag,
|
|
234
|
+
puppet_logdest_flag,
|
|
235
|
+
puppet_test_flag,
|
|
236
|
+
puppet_onetime_flag,
|
|
237
|
+
puppet_no_daemonize_flag,
|
|
238
|
+
puppet_noop_flag,
|
|
239
|
+
puppet_verbose_flag,
|
|
240
|
+
puppet_debug_flag
|
|
241
|
+
].join(' ')
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
protected
|
|
246
|
+
|
|
247
|
+
def load_needed_dependencies!
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def puppet_config
|
|
251
|
+
config[:puppet_config_path]
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def puppet_debian_version
|
|
255
|
+
config[:puppet_version] ? "=#{config[:puppet_version]}" : nil
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def puppet_redhat_version
|
|
259
|
+
config[:puppet_version] ? "-#{config[:puppet_version]}" : nil
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def puppet_noop_flag
|
|
263
|
+
config[:puppet_noop] ? '--noop' : nil
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def puppet_debug_flag
|
|
267
|
+
config[:puppet_debug] ? '-d' : nil
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def puppet_verbose_flag
|
|
271
|
+
config[:puppet_verbose] ? '-v' : nil
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def puppet_platform
|
|
275
|
+
config[:puppet_platform].to_s.downcase
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def update_packages_debian_cmd
|
|
279
|
+
config[:update_package_repos] ? "#{sudo_env('apt-get')} update" : nil
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def update_packages_redhat_cmd
|
|
283
|
+
config[:update_package_repos] ? "#{sudo_env('yum')} makecache" : nil
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def sudo_env(pm)
|
|
287
|
+
http_proxy ? "#{sudo('env')} http_proxy=#{http_proxy} #{pm}" : "#{sudo(pm)}"
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def custom_facts
|
|
291
|
+
return nil if config[:custom_facts].none?
|
|
292
|
+
bash_vars = config[:custom_facts].map { |k, v| "FACTER_#{k}=#{v}" }.join(' ')
|
|
293
|
+
bash_vars = "export #{bash_vars};"
|
|
294
|
+
debug(bash_vars)
|
|
295
|
+
bash_vars
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def puppet_server_flag
|
|
299
|
+
config[:puppet_server] ? "--server=#{config[:puppet_server]}" : nil
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def puppet_masterport_flag
|
|
303
|
+
config[:puppet_masterport] ? '--masterport=#{config[:puppet_masterport]}' : nil
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def puppet_detailed_exitcodes_flag
|
|
307
|
+
config[:puppet_detailed_exitcodes] ? '--detailed-exitcodes' : nil
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def puppet_logdest_flag
|
|
311
|
+
config[:puppet_logdest] ? "--logdest=#{config[:puppet_logdest]}" : nil
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def puppet_test_flag
|
|
315
|
+
config[:puppet_test] ? '--test' : nil
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def puppet_onetime_flag
|
|
319
|
+
config[:puppet_onetime] ? '--onetime' : nil
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
def puppet_no_daemonize_flag
|
|
323
|
+
config[:puppet_no_daemonize] ? '--no-daemonize' : nil
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def puppet_no_daemonize
|
|
327
|
+
config[:puppet_no_daemonize]
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def puppet_server
|
|
331
|
+
config[:puppet_server]
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def puppet_certname_flag
|
|
335
|
+
config[:puppet_certname] ? "--certname=#{config[:puppet_certname]}" : nil
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def puppet_digest_flag
|
|
339
|
+
config[:puppet_digest] ? "--digest=#{config[:puppet_digest]}" : nil
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def puppet_apt_repo
|
|
343
|
+
config[:puppet_apt_repo]
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def puppet_apt_repo_file
|
|
347
|
+
config[:puppet_apt_repo].split('/').last
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def puppet_yum_repo
|
|
351
|
+
config[:puppet_yum_repo]
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def proxy_parm
|
|
355
|
+
http_proxy ? "--httpproxy #{URI.parse(http_proxy).host.downcase} --httpport #{URI.parse(http_proxy).port} " : nil
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def gem_proxy_parm
|
|
359
|
+
http_proxy ? "--http-proxy #{http_proxy}" : nil
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
def wget_proxy_parm
|
|
363
|
+
http_proxy ? "-e use_proxy=yes -e http_proxy=#{http_proxy}" : nil
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
def http_proxy
|
|
367
|
+
config[:http_proxy]
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def chef_url
|
|
371
|
+
config[:chef_bootstrap_url]
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def prepare_puppet_config
|
|
375
|
+
return unless puppet_config
|
|
376
|
+
|
|
377
|
+
info('Preparing puppet.conf')
|
|
378
|
+
debug("Using puppet config from #{puppet_config}")
|
|
379
|
+
|
|
380
|
+
FileUtils.cp_r(puppet_config, File.join(sandbox_path, 'puppet.conf'))
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
end
|