kitchen-ansible 0.43.1 → 0.44.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,39 @@
1
- # encoding: utf-8
2
-
3
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
- require 'kitchen-ansible/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = 'kitchen-ansible'
8
- s.license = 'Apache-2.0'
9
- s.version = Kitchen::Ansible::VERSION
10
- s.authors = ['Neill Turner']
11
- s.email = ['neillwturner@gmail.com']
12
- s.homepage = 'https://github.com/neillturner/kitchen-ansible'
13
- s.summary = 'ansible provisioner for test-kitchen'
14
- candidates = Dir.glob('{lib}/**/*') + ['README.md', 'provisioner_options.md', 'kitchen-ansible.gemspec']
15
- s.files = candidates.sort
16
- s.platform = Gem::Platform::RUBY
17
- s.require_paths = ['lib']
18
- s.rubyforge_project = '[none]'
19
- s.description = <<-EOF
20
- == DESCRIPTION:
21
-
22
- Ansible Provisioner for Test Kitchen
23
-
24
- == FEATURES:
25
-
26
- Supports running ansible-playbook
27
-
28
- EOF
29
- s.add_runtime_dependency 'test-kitchen', '~> 1.4'
30
-
31
- s.add_development_dependency 'rspec'
32
- s.add_development_dependency 'pry'
33
- s.add_development_dependency 'rake'
34
- s.add_runtime_dependency 'librarian-ansible'
35
- if RUBY_VERSION >= '2.0'
36
- s.add_dependency 'net-ssh', '~> 3'
37
- else
38
- s.add_dependency 'net-ssh', '~> 2.9'
39
- end
40
- end
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+ require 'kitchen-ansible/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'kitchen-ansible'
8
+ s.license = 'Apache-2.0'
9
+ s.version = Kitchen::Ansible::VERSION
10
+ s.authors = ['Neill Turner']
11
+ s.email = ['neillwturner@gmail.com']
12
+ s.homepage = 'https://github.com/neillturner/kitchen-ansible'
13
+ s.summary = 'ansible provisioner for test-kitchen'
14
+ candidates = Dir.glob('{lib}/**/*') + ['README.md', 'provisioner_options.md', 'kitchen-ansible.gemspec']
15
+ s.files = candidates.sort
16
+ s.platform = Gem::Platform::RUBY
17
+ s.require_paths = ['lib']
18
+ s.rubyforge_project = '[none]'
19
+ s.description = <<-EOF
20
+ == DESCRIPTION:
21
+
22
+ Ansible Provisioner for Test Kitchen
23
+
24
+ == FEATURES:
25
+
26
+ Supports running ansible-playbook
27
+
28
+ EOF
29
+ s.add_runtime_dependency 'test-kitchen', '~> 1.4'
30
+
31
+ s.add_development_dependency 'rspec'
32
+ s.add_development_dependency 'pry'
33
+ s.add_development_dependency 'rake'
34
+ if RUBY_VERSION >= '2.0'
35
+ s.add_dependency 'net-ssh', '~> 3'
36
+ else
37
+ s.add_dependency 'net-ssh', '~> 2.9'
38
+ end
39
+ end
@@ -1,6 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
- module Kitchen
3
- module Ansible
4
- VERSION = '0.43.1'
5
- end
6
- end
1
+ # -*- encoding: utf-8 -*-
2
+ module Kitchen
3
+ module Ansible
4
+ VERSION = '0.44.2'
5
+ end
6
+ end
@@ -1,169 +1,170 @@
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
- module Provisioner
24
- module Ansible
25
- #
26
- # Ansible Playbook provisioner.
27
- #
28
- class Config
29
- include Kitchen::Configurable
30
-
31
- attr_accessor :instance
32
-
33
- default_config :ansible_sudo, true
34
- default_config :ansible_verbose, false
35
- default_config :require_ansible_omnibus, false
36
- default_config :ansible_omnibus_url, 'https://raw.githubusercontent.com/neillturner/omnibus-ansible/master/ansible_install.sh'
37
- default_config :ansible_omnibus_remote_path, '/opt/ansible'
38
- default_config :ansible_version, nil
39
- default_config :require_ansible_repo, true
40
- default_config :enable_yum_epel, false
41
- default_config :extra_vars, {}
42
- default_config :tags, []
43
- default_config :ansible_apt_repo, 'ppa:ansible/ansible'
44
- default_config :ansible_yum_repo, nil
45
- default_config :ansible_sles_repo, 'http://download.opensuse.org/repositories/systemsmanagement/SLE_12/systemsmanagement.repo'
46
- default_config :python_sles_repo, 'http://download.opensuse.org/repositories/devel:/languages:/python/SLE_12/devel:languages:python.repo'
47
- default_config :chef_bootstrap_url, 'https://www.getchef.com/chef/install.sh'
48
- # Providing we have Ruby >= 2.0 we only need Ruby. Leaving default to install Chef Omnibus for backwards compatibility.
49
- # Note: if using kitchen-verifer-serverspec your we can avoid needing Ruby too.
50
- # (Reference: https://github.com/neillturner/kitchen-ansible/issues/66 )
51
- default_config :require_chef_for_busser, true
52
- default_config :require_ruby_for_busser, false
53
- default_config :require_windows_support, false
54
- default_config :requirements_path, false
55
- default_config :ssh_known_hosts, nil
56
- default_config :ansible_verbose, false
57
- default_config :ansible_verbosity, 1
58
- default_config :ansible_check, false
59
- default_config :ansible_diff, false
60
- default_config :ansible_platform, ''
61
- default_config :ansible_connection, 'local'
62
- default_config :update_package_repos, true
63
- default_config :require_ansible_source, false
64
- default_config :ansible_source_rev, nil
65
- default_config :http_proxy, nil
66
- default_config :https_proxy, nil
67
- default_config :no_proxy, nil
68
- default_config :ansible_playbook_command, nil
69
- default_config :ansible_host_key_checking, true
70
- default_config :idempotency_test, nil
71
- default_config :ansible_inventory, nil
72
- default_config :ansible_inventory_file, nil
73
- default_config :ansible_limit, nil
74
-
75
- default_config :playbook do |provisioner|
76
- provisioner.calculate_path('default.yml', :file) ||
77
- fail('No playbook found or specified! Please either set a playbook in your .kitchen.yml config, or create a default playbook in test/integration/<suite_name>/ansible/default.yml, test/integration/<suite_name>/default.yml, test/integration/default.yml or in default.yml in the top level')
78
- end
79
-
80
- default_config :roles_path do |provisioner|
81
- provisioner.calculate_path('roles') ||
82
- fail('No roles_path detected. Please specify one in .kitchen.yml')
83
- end
84
-
85
- default_config :group_vars_path do |provisioner|
86
- provisioner.calculate_path('group_vars', :directory)
87
- end
88
-
89
- default_config :additional_copy_path do |provisioner|
90
- provisioner.calculate_path('additional_copy', :directory)
91
- end
92
-
93
- default_config :host_vars_path do |provisioner|
94
- provisioner.calculate_path('host_vars', :directory)
95
- end
96
-
97
- default_config :modules_path do |provisioner|
98
- provisioner.calculate_path('modules', :directory)
99
- end
100
-
101
- default_config :ansiblefile_path do |provisioner|
102
- provisioner.calculate_path('Ansiblefile', :file)
103
- end
104
-
105
- default_config :library_plugins_path do |provisioner|
106
- provisioner.calculate_path('library', :directory)
107
- end
108
-
109
- default_config :callback_plugins_path do |provisioner|
110
- provisioner.calculate_path('callback_plugins', :directory)
111
- end
112
-
113
- default_config :filter_plugins_path do |provisioner|
114
- provisioner.calculate_path('filter_plugins', :directory)
115
- end
116
-
117
- default_config :lookup_plugins_path do |provisioner|
118
- provisioner.calculate_path('lookup_plugins', :directory)
119
- end
120
-
121
- default_config :ansible_vault_password_file do |provisioner|
122
- provisioner.calculate_path('ansible-vault-password', :file)
123
- end
124
-
125
- default_config :kerberos_conf_file do |provisioner|
126
- provisioner.calculate_path('kerberos_conf', :file)
127
- end
128
-
129
- def initialize(config = {})
130
- init_config(config)
131
- end
132
-
133
- def []=(attr, val)
134
- config[attr] = val
135
- end
136
-
137
- def [](attr)
138
- config[attr]
139
- end
140
-
141
- def key?(k)
142
- config.key?(k)
143
- end
144
-
145
- def keys
146
- config.keys
147
- end
148
-
149
- def calculate_path(path, type = :directory)
150
- unless instance
151
- fail 'Please ensure that an instance is provided before calling calculate_path'
152
- end
153
-
154
- base = config[:test_base_path]
155
- candidates = []
156
- candidates << File.join(base, instance.suite.name, 'ansible', path)
157
- candidates << File.join(base, instance.suite.name, path)
158
- candidates << File.join(base, path)
159
- candidates << File.join(Dir.pwd, path)
160
- candidates << File.join(Dir.pwd) if path == 'roles'
161
-
162
- candidates.find do |c|
163
- type == :directory ? File.directory?(c) : File.file?(c)
164
- end
165
- end
166
- end
167
- end
168
- end
169
- end
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
+ module Provisioner
24
+ module Ansible
25
+ #
26
+ # Ansible Playbook provisioner.
27
+ #
28
+ class Config
29
+ include Kitchen::Configurable
30
+
31
+ attr_accessor :instance
32
+
33
+ default_config :ansible_sudo, true
34
+ default_config :ansible_verbose, false
35
+ default_config :require_ansible_omnibus, false
36
+ default_config :ansible_omnibus_url, 'https://raw.githubusercontent.com/neillturner/omnibus-ansible/master/ansible_install.sh'
37
+ default_config :ansible_omnibus_remote_path, '/opt/ansible'
38
+ default_config :ansible_version, nil
39
+ default_config :require_ansible_repo, true
40
+ default_config :enable_yum_epel, false
41
+ default_config :extra_vars, {}
42
+ default_config :tags, []
43
+ default_config :ansible_apt_repo, 'ppa:ansible/ansible'
44
+ default_config :ansible_yum_repo, nil
45
+ default_config :ansible_sles_repo, 'http://download.opensuse.org/repositories/systemsmanagement/SLE_12/systemsmanagement.repo'
46
+ default_config :python_sles_repo, 'http://download.opensuse.org/repositories/devel:/languages:/python/SLE_12/devel:languages:python.repo'
47
+ default_config :chef_bootstrap_url, 'https://www.getchef.com/chef/install.sh'
48
+ # Providing we have Ruby >= 2.0 we only need Ruby. Leaving default to install Chef Omnibus for backwards compatibility.
49
+ # Note: if using kitchen-verifer-serverspec your we can avoid needing Ruby too.
50
+ # (Reference: https://github.com/neillturner/kitchen-ansible/issues/66 )
51
+ default_config :require_chef_for_busser, true
52
+ default_config :require_ruby_for_busser, false
53
+ default_config :require_windows_support, false
54
+ default_config :requirements_path, false
55
+ default_config :ssh_known_hosts, nil
56
+ default_config :ansible_verbose, false
57
+ default_config :ansible_verbosity, 1
58
+ default_config :ansible_check, false
59
+ default_config :ansible_diff, false
60
+ default_config :ansible_platform, ''
61
+ default_config :ansible_connection, 'local'
62
+ default_config :update_package_repos, true
63
+ default_config :require_ansible_source, false
64
+ default_config :ansible_source_rev, nil
65
+ default_config :http_proxy, nil
66
+ default_config :https_proxy, nil
67
+ default_config :no_proxy, nil
68
+ default_config :ansible_playbook_command, nil
69
+ default_config :ansible_host_key_checking, true
70
+ default_config :idempotency_test, nil
71
+ default_config :ansible_inventory, nil
72
+ default_config :ansible_inventory_file, nil
73
+ default_config :ansible_limit, nil
74
+ default_config :ignore_paths_from_root, []
75
+
76
+ default_config :playbook do |provisioner|
77
+ provisioner.calculate_path('default.yml', :file) ||
78
+ fail('No playbook found or specified! Please either set a playbook in your .kitchen.yml config, or create a default playbook in test/integration/<suite_name>/ansible/default.yml, test/integration/<suite_name>/default.yml, test/integration/default.yml or in default.yml in the top level')
79
+ end
80
+
81
+ default_config :roles_path do |provisioner|
82
+ provisioner.calculate_path('roles') ||
83
+ fail('No roles_path detected. Please specify one in .kitchen.yml')
84
+ end
85
+
86
+ default_config :group_vars_path do |provisioner|
87
+ provisioner.calculate_path('group_vars', :directory)
88
+ end
89
+
90
+ default_config :additional_copy_path do |provisioner|
91
+ provisioner.calculate_path('additional_copy', :directory)
92
+ end
93
+
94
+ default_config :host_vars_path do |provisioner|
95
+ provisioner.calculate_path('host_vars', :directory)
96
+ end
97
+
98
+ default_config :modules_path do |provisioner|
99
+ provisioner.calculate_path('modules', :directory)
100
+ end
101
+
102
+ default_config :ansiblefile_path do |provisioner|
103
+ provisioner.calculate_path('Ansiblefile', :file)
104
+ end
105
+
106
+ default_config :library_plugins_path do |provisioner|
107
+ provisioner.calculate_path('library', :directory)
108
+ end
109
+
110
+ default_config :callback_plugins_path do |provisioner|
111
+ provisioner.calculate_path('callback_plugins', :directory)
112
+ end
113
+
114
+ default_config :filter_plugins_path do |provisioner|
115
+ provisioner.calculate_path('filter_plugins', :directory)
116
+ end
117
+
118
+ default_config :lookup_plugins_path do |provisioner|
119
+ provisioner.calculate_path('lookup_plugins', :directory)
120
+ end
121
+
122
+ default_config :ansible_vault_password_file do |provisioner|
123
+ provisioner.calculate_path('ansible-vault-password', :file)
124
+ end
125
+
126
+ default_config :kerberos_conf_file do |provisioner|
127
+ provisioner.calculate_path('kerberos_conf', :file)
128
+ end
129
+
130
+ def initialize(config = {})
131
+ init_config(config)
132
+ end
133
+
134
+ def []=(attr, val)
135
+ config[attr] = val
136
+ end
137
+
138
+ def [](attr)
139
+ config[attr]
140
+ end
141
+
142
+ def key?(k)
143
+ config.key?(k)
144
+ end
145
+
146
+ def keys
147
+ config.keys
148
+ end
149
+
150
+ def calculate_path(path, type = :directory)
151
+ unless instance
152
+ fail 'Please ensure that an instance is provided before calling calculate_path'
153
+ end
154
+
155
+ base = config[:test_base_path]
156
+ candidates = []
157
+ candidates << File.join(base, instance.suite.name, 'ansible', path)
158
+ candidates << File.join(base, instance.suite.name, path)
159
+ candidates << File.join(base, path)
160
+ candidates << File.join(Dir.pwd, path)
161
+ candidates << File.join(Dir.pwd) if path == 'roles'
162
+
163
+ candidates.find do |c|
164
+ type == :directory ? File.directory?(c) : File.file?(c)
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
170
+ 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 Ansible
25
- # Ansible module resolver that uses Librarian-Ansible and a Ansiblefile to
26
- # calculate # dependencies.
27
- #
28
- class Librarian
29
- include Logging
30
-
31
- def initialize(ansiblefile, path, logger = Kitchen.logger)
32
- @ansiblefile = ansiblefile
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::Ansible::VERSION
43
- info("Resolving role dependencies with Librarian-Ansible #{version}...")
44
- debug("Using Ansiblefile from #{ansiblefile}")
45
-
46
- env = ::Librarian::Ansible::Environment.new(
47
- project_path: File.dirname(ansiblefile))
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 :ansiblefile, :path, :logger
54
-
55
- def self.load_librarian!(logger)
56
- first_load = require 'librarian/ansible'
57
- require 'librarian/ansible/environment'
58
- require 'librarian/action/resolve'
59
- require 'librarian/action/install'
60
-
61
- version = ::Librarian::Ansible::VERSION
62
- if first_load
63
- logger.debug("Librarian-Ansible #{version} library loaded")
64
- else
65
- logger.debug("Librarian-Ansible #{version} previously loaded")
66
- end
67
- rescue LoadError => e
68
- logger.fatal("The `librarian-ansible' gem is missing and must be installed" \
69
- ' or cannot be properly activated. Run' \
70
- ' `gem install librarian-ansible` or add the following to your' \
71
- " Gemfile if you are using Bundler: `gem 'librarian-ansible'`.")
72
- raise UserError,
73
- "Could not load or activate Librarian-Ansible (#{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 Ansible
25
+ # Ansible module resolver that uses Librarian-Ansible and a Ansiblefile to
26
+ # calculate # dependencies.
27
+ #
28
+ class Librarian
29
+ include Logging
30
+
31
+ def initialize(ansiblefile, path, logger = Kitchen.logger)
32
+ @ansiblefile = ansiblefile
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::Ansible::VERSION
43
+ info("Resolving role dependencies with Librarian-Ansible #{version}...")
44
+ debug("Using Ansiblefile from #{ansiblefile}")
45
+
46
+ env = ::Librarian::Ansible::Environment.new(
47
+ project_path: File.dirname(ansiblefile))
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 :ansiblefile, :path, :logger
54
+
55
+ def self.load_librarian!(logger)
56
+ first_load = require 'librarian/ansible'
57
+ require 'librarian/ansible/environment'
58
+ require 'librarian/action/resolve'
59
+ require 'librarian/action/install'
60
+
61
+ version = ::Librarian::Ansible::VERSION
62
+ if first_load
63
+ logger.debug("Librarian-Ansible #{version} library loaded")
64
+ else
65
+ logger.debug("Librarian-Ansible #{version} previously loaded")
66
+ end
67
+ rescue LoadError => e
68
+ logger.fatal("The `librarian-ansible' gem is missing and must be installed" \
69
+ ' or cannot be properly activated. Run' \
70
+ ' `gem install librarian-ansible` or add the following to your' \
71
+ " Gemfile if you are using Bundler: `gem 'librarian-ansible'`.")
72
+ raise UserError,
73
+ "Could not load or activate Librarian-Ansible (#{e.message})"
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end