kitchen-ansible 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +195 -195
- data/kitchen-ansible.gemspec +35 -35
- data/lib/kitchen-ansible/version.rb +5 -5
- data/lib/kitchen/provisioner/ansible/config.rb +150 -149
- data/lib/kitchen/provisioner/ansible/librarian.rb +83 -83
- data/lib/kitchen/provisioner/ansible_playbook.rb +709 -695
- data/provisioner_options.md +96 -95
- metadata +3 -3
@@ -1,5 +1,5 @@
|
|
1
|
-
module Kitchen
|
2
|
-
module Ansible
|
3
|
-
VERSION = "0.0.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Kitchen
|
2
|
+
module Ansible
|
3
|
+
VERSION = "0.0.22"
|
4
|
+
end
|
5
|
+
end
|
@@ -1,149 +1,150 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Michael Heap (<m@michaelheap.com>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2015 Michael Heap
|
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
|
-
|
20
|
-
require 'json'
|
21
|
-
|
22
|
-
module Kitchen
|
23
|
-
|
24
|
-
module Provisioner
|
25
|
-
|
26
|
-
module Ansible
|
27
|
-
#
|
28
|
-
# Ansible Playbook provisioner.
|
29
|
-
#
|
30
|
-
class Config
|
31
|
-
include Kitchen::Configurable
|
32
|
-
|
33
|
-
attr_reader :instance
|
34
|
-
|
35
|
-
default_config :
|
36
|
-
default_config :
|
37
|
-
default_config :
|
38
|
-
default_config :
|
39
|
-
default_config :
|
40
|
-
default_config :
|
41
|
-
default_config :
|
42
|
-
default_config :
|
43
|
-
default_config :
|
44
|
-
default_config :
|
45
|
-
default_config :
|
46
|
-
default_config :
|
47
|
-
default_config :
|
48
|
-
default_config :
|
49
|
-
default_config :
|
50
|
-
default_config :
|
51
|
-
default_config :
|
52
|
-
default_config :
|
53
|
-
default_config :
|
54
|
-
default_config :
|
55
|
-
default_config :
|
56
|
-
default_config :
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
candidates
|
133
|
-
candidates << File.join(base, instance.suite.name, path)
|
134
|
-
candidates << File.join(base, path)
|
135
|
-
candidates << File.join(
|
136
|
-
candidates << File.join(Dir.pwd
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Michael Heap (<m@michaelheap.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2015 Michael Heap
|
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
|
+
|
20
|
+
require 'json'
|
21
|
+
|
22
|
+
module Kitchen
|
23
|
+
|
24
|
+
module Provisioner
|
25
|
+
|
26
|
+
module Ansible
|
27
|
+
#
|
28
|
+
# Ansible Playbook provisioner.
|
29
|
+
#
|
30
|
+
class Config
|
31
|
+
include Kitchen::Configurable
|
32
|
+
|
33
|
+
attr_reader :instance
|
34
|
+
|
35
|
+
default_config :ansible_sudo, true
|
36
|
+
default_config :ansible_verbose, false
|
37
|
+
default_config :require_ansible_omnibus, false
|
38
|
+
default_config :ansible_omnibus_url, nil
|
39
|
+
default_config :ansible_omnibus_remote_path, '/opt/ansible'
|
40
|
+
default_config :ansible_version, nil
|
41
|
+
default_config :require_ansible_repo, true
|
42
|
+
default_config :extra_vars, {}
|
43
|
+
default_config :tags, []
|
44
|
+
default_config :ansible_apt_repo, "ppa:ansible/ansible"
|
45
|
+
default_config :ansible_yum_repo, "https://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
|
46
|
+
default_config :chef_bootstrap_url, "https://www.getchef.com/chef/install.sh"
|
47
|
+
default_config :require_chef_for_busser, false
|
48
|
+
default_config :require_ruby_for_busser, true
|
49
|
+
default_config :requirements_path, false
|
50
|
+
default_config :ansible_verbose, false
|
51
|
+
default_config :ansible_verbosity, 1
|
52
|
+
default_config :ansible_check, false
|
53
|
+
default_config :ansible_diff, false
|
54
|
+
default_config :ansible_platform, ''
|
55
|
+
default_config :ansible_connection, 'local'
|
56
|
+
default_config :update_package_repos, true
|
57
|
+
default_config :require_ansible_source, false
|
58
|
+
|
59
|
+
default_config :playbook do |provisioner|
|
60
|
+
provisioner.calculate_path('default.yml', :file) or
|
61
|
+
raise "No playbook found or specified! Please either set a playbook in your .kitchen.yml config, or create a default wrapper playbook for your role in test/integration/playbooks/default.yml or test/integration/default.yml"
|
62
|
+
end
|
63
|
+
|
64
|
+
default_config :roles_path do |provisioner|
|
65
|
+
provisioner.calculate_path('roles') or
|
66
|
+
raise 'No roles_path detected. Please specify one in .kitchen.yml'
|
67
|
+
end
|
68
|
+
|
69
|
+
default_config :group_vars_path do |provisioner|
|
70
|
+
provisioner.calculate_path('group_vars', :directory)
|
71
|
+
end
|
72
|
+
|
73
|
+
default_config :additional_copy_path do |provisioner|
|
74
|
+
provisioner.calculate_path('additional_copy', :directory)
|
75
|
+
end
|
76
|
+
|
77
|
+
default_config :host_vars_path do |provisioner|
|
78
|
+
provisioner.calculate_path('host_vars', :directory)
|
79
|
+
end
|
80
|
+
|
81
|
+
default_config :modules_path do |provisioner|
|
82
|
+
provisioner.calculate_path('modules', :directory)
|
83
|
+
end
|
84
|
+
|
85
|
+
default_config :ansiblefile_path do |provisioner|
|
86
|
+
provisioner.calculate_path('Ansiblefile', :file)
|
87
|
+
end
|
88
|
+
|
89
|
+
default_config :filter_plugins_path do |provisioner|
|
90
|
+
provisioner.calculate_path('filter_plugins', :directory)
|
91
|
+
end
|
92
|
+
|
93
|
+
default_config :ansible_vault_password_file do |provisioner|
|
94
|
+
provisioner.calculate_path('ansible-vault-password', :file)
|
95
|
+
end
|
96
|
+
|
97
|
+
default_config :ansible_inventory_file do |provisioner|
|
98
|
+
provisioner.calculate_path('hosts', :file)
|
99
|
+
end
|
100
|
+
|
101
|
+
def initialize(config = {})
|
102
|
+
init_config(config)
|
103
|
+
end
|
104
|
+
|
105
|
+
def set_instance(instance)
|
106
|
+
@instance = instance
|
107
|
+
end
|
108
|
+
|
109
|
+
def []=(attr, val)
|
110
|
+
config[attr] = val
|
111
|
+
end
|
112
|
+
|
113
|
+
def [](attr)
|
114
|
+
config[attr]
|
115
|
+
end
|
116
|
+
|
117
|
+
def key?(k)
|
118
|
+
return config.key?(k)
|
119
|
+
end
|
120
|
+
|
121
|
+
def keys
|
122
|
+
config.keys
|
123
|
+
end
|
124
|
+
|
125
|
+
def calculate_path(path, type = :directory)
|
126
|
+
|
127
|
+
if not instance
|
128
|
+
raise "Please ensure that an instance is provided before calling calculate_path"
|
129
|
+
end
|
130
|
+
|
131
|
+
base = config[:test_base_path]
|
132
|
+
candidates = []
|
133
|
+
candidates << File.join(base, instance.suite.name, 'ansible', path)
|
134
|
+
candidates << File.join(base, instance.suite.name, path)
|
135
|
+
candidates << File.join(base, path)
|
136
|
+
candidates << File.join(Dir.pwd, path)
|
137
|
+
candidates << File.join(Dir.pwd) if path == 'roles'
|
138
|
+
|
139
|
+
candidates.find do |c|
|
140
|
+
type == :directory ? File.directory?(c) : File.file?(c)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -1,83 +1,83 @@
|
|
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
|
-
|
24
|
-
module Provisioner
|
25
|
-
|
26
|
-
module Ansible
|
27
|
-
|
28
|
-
# Ansible module resolver that uses Librarian-Ansible and a Ansiblefile to
|
29
|
-
# calculate # dependencies.
|
30
|
-
#
|
31
|
-
class Librarian
|
32
|
-
|
33
|
-
include Logging
|
34
|
-
|
35
|
-
|
36
|
-
def initialize(ansiblefile, path, logger = Kitchen.logger)
|
37
|
-
@ansiblefile = ansiblefile
|
38
|
-
@path = path
|
39
|
-
@logger = logger
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.load!(logger = Kitchen.logger)
|
43
|
-
load_librarian!(logger)
|
44
|
-
end
|
45
|
-
|
46
|
-
def resolve
|
47
|
-
version = ::Librarian::Ansible::VERSION
|
48
|
-
info("Resolving role dependencies with Librarian-Ansible #{version}...")
|
49
|
-
debug("Using Ansiblefile from #{ansiblefile}")
|
50
|
-
|
51
|
-
env = ::Librarian::Ansible::Environment.new(
|
52
|
-
:project_path => File.dirname(ansiblefile))
|
53
|
-
env.config_db.local["path"] = path
|
54
|
-
::Librarian::Action::Resolve.new(env).run
|
55
|
-
::Librarian::Action::Install.new(env).run
|
56
|
-
end
|
57
|
-
|
58
|
-
attr_reader :ansiblefile, :path, :logger
|
59
|
-
|
60
|
-
def self.load_librarian!(logger)
|
61
|
-
first_load = require 'librarian/ansible'
|
62
|
-
require 'librarian/ansible/environment'
|
63
|
-
require 'librarian/action/resolve'
|
64
|
-
require 'librarian/action/install'
|
65
|
-
|
66
|
-
version = ::Librarian::Ansible::VERSION
|
67
|
-
if first_load
|
68
|
-
logger.debug("Librarian-Ansible #{version} library loaded")
|
69
|
-
else
|
70
|
-
logger.debug("Librarian-Ansible #{version} previously loaded")
|
71
|
-
end
|
72
|
-
rescue LoadError => e
|
73
|
-
logger.fatal("The `librarian-ansible' gem is missing and must be installed" +
|
74
|
-
" or cannot be properly activated. Run" +
|
75
|
-
" `gem install librarian-ansible` or add the following to your" +
|
76
|
-
" Gemfile if you are using Bundler: `gem 'librarian-ansible'`.")
|
77
|
-
raise UserError,
|
78
|
-
"Could not load or activate Librarian-Ansible (#{e.message})"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
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
|
+
|
24
|
+
module Provisioner
|
25
|
+
|
26
|
+
module Ansible
|
27
|
+
|
28
|
+
# Ansible module resolver that uses Librarian-Ansible and a Ansiblefile to
|
29
|
+
# calculate # dependencies.
|
30
|
+
#
|
31
|
+
class Librarian
|
32
|
+
|
33
|
+
include Logging
|
34
|
+
|
35
|
+
|
36
|
+
def initialize(ansiblefile, path, logger = Kitchen.logger)
|
37
|
+
@ansiblefile = ansiblefile
|
38
|
+
@path = path
|
39
|
+
@logger = logger
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.load!(logger = Kitchen.logger)
|
43
|
+
load_librarian!(logger)
|
44
|
+
end
|
45
|
+
|
46
|
+
def resolve
|
47
|
+
version = ::Librarian::Ansible::VERSION
|
48
|
+
info("Resolving role dependencies with Librarian-Ansible #{version}...")
|
49
|
+
debug("Using Ansiblefile from #{ansiblefile}")
|
50
|
+
|
51
|
+
env = ::Librarian::Ansible::Environment.new(
|
52
|
+
:project_path => File.dirname(ansiblefile))
|
53
|
+
env.config_db.local["path"] = path
|
54
|
+
::Librarian::Action::Resolve.new(env).run
|
55
|
+
::Librarian::Action::Install.new(env).run
|
56
|
+
end
|
57
|
+
|
58
|
+
attr_reader :ansiblefile, :path, :logger
|
59
|
+
|
60
|
+
def self.load_librarian!(logger)
|
61
|
+
first_load = require 'librarian/ansible'
|
62
|
+
require 'librarian/ansible/environment'
|
63
|
+
require 'librarian/action/resolve'
|
64
|
+
require 'librarian/action/install'
|
65
|
+
|
66
|
+
version = ::Librarian::Ansible::VERSION
|
67
|
+
if first_load
|
68
|
+
logger.debug("Librarian-Ansible #{version} library loaded")
|
69
|
+
else
|
70
|
+
logger.debug("Librarian-Ansible #{version} previously loaded")
|
71
|
+
end
|
72
|
+
rescue LoadError => e
|
73
|
+
logger.fatal("The `librarian-ansible' gem is missing and must be installed" +
|
74
|
+
" or cannot be properly activated. Run" +
|
75
|
+
" `gem install librarian-ansible` or add the following to your" +
|
76
|
+
" Gemfile if you are using Bundler: `gem 'librarian-ansible'`.")
|
77
|
+
raise UserError,
|
78
|
+
"Could not load or activate Librarian-Ansible (#{e.message})"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|