kitchen-ansible 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,35 +1,35 @@
1
- # encoding: utf-8
2
-
3
- $:.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'
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
- end
1
+ # encoding: utf-8
2
+
3
+ $:.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'
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
+ end
@@ -1,5 +1,5 @@
1
- module Kitchen
2
- module Ansible
3
- VERSION = "0.0.25"
4
- end
5
- end
1
+ module Kitchen
2
+ module Ansible
3
+ VERSION = "0.0.26"
4
+ end
5
+ end
@@ -1,161 +1,162 @@
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, 'https://raw.githubusercontent.com/neillturner/omnibus-ansible/master/ansible_install.sh'
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 :enable_yum_epel, false
43
- default_config :extra_vars, {}
44
- default_config :tags, []
45
- default_config :ansible_apt_repo, "ppa:ansible/ansible"
46
- default_config :ansible_yum_repo, "https://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
47
- default_config :ansible_sles_repo, "http://download.opensuse.org/repositories/systemsmanagement/SLE_12/systemsmanagement.repo"
48
- default_config :python_sles_repo, "http://download.opensuse.org/repositories/devel:/languages:/python/SLE_12/devel:languages:python.repo"
49
- default_config :chef_bootstrap_url, "https://www.getchef.com/chef/install.sh"
50
- # Until we can truly make busser work without /opt/chef/embedded/bin/gem being installed, we still need Chef Omnibus
51
- # (Reference: https://github.com/neillturner/kitchen-ansible/issues/66 )
52
- default_config :require_chef_for_busser, true
53
- default_config :require_ruby_for_busser, false
54
- default_config :requirements_path, false
55
- default_config :ansible_verbose, false
56
- default_config :ansible_verbosity, 1
57
- default_config :ansible_check, false
58
- default_config :ansible_diff, false
59
- default_config :ansible_platform, ''
60
- default_config :ansible_connection, 'local'
61
- default_config :update_package_repos, true
62
- default_config :require_ansible_source, false
63
- default_config :http_proxy, nil
64
- default_config :https_proxy, nil
65
-
66
- default_config :playbook do |provisioner|
67
- provisioner.calculate_path('default.yml', :file) or
68
- 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"
69
- end
70
-
71
- default_config :roles_path do |provisioner|
72
- provisioner.calculate_path('roles') or
73
- raise 'No roles_path detected. Please specify one in .kitchen.yml'
74
- end
75
-
76
- default_config :group_vars_path do |provisioner|
77
- provisioner.calculate_path('group_vars', :directory)
78
- end
79
-
80
- default_config :additional_copy_path do |provisioner|
81
- provisioner.calculate_path('additional_copy', :directory)
82
- end
83
-
84
- default_config :host_vars_path do |provisioner|
85
- provisioner.calculate_path('host_vars', :directory)
86
- end
87
-
88
- default_config :modules_path do |provisioner|
89
- provisioner.calculate_path('modules', :directory)
90
- end
91
-
92
- default_config :ansiblefile_path do |provisioner|
93
- provisioner.calculate_path('Ansiblefile', :file)
94
- end
95
-
96
- default_config :filter_plugins_path do |provisioner|
97
- provisioner.calculate_path('filter_plugins', :directory)
98
- end
99
-
100
- default_config :lookup_plugins_path do |provisioner|
101
- provisioner.calculate_path('lookup_plugins', :directory)
102
- end
103
-
104
- default_config :ansible_vault_password_file do |provisioner|
105
- provisioner.calculate_path('ansible-vault-password', :file)
106
- end
107
-
108
- default_config :ansible_inventory_file do |provisioner|
109
- provisioner.calculate_path('hosts', :file)
110
- end
111
-
112
- def initialize(config = {})
113
- init_config(config)
114
- end
115
-
116
- def set_instance(instance)
117
- @instance = instance
118
- end
119
-
120
- def []=(attr, val)
121
- config[attr] = val
122
- end
123
-
124
- def [](attr)
125
- config[attr]
126
- end
127
-
128
- def key?(k)
129
- return config.key?(k)
130
- end
131
-
132
- def keys
133
- config.keys
134
- end
135
-
136
- def calculate_path(path, type = :directory)
137
-
138
- if not instance
139
- raise "Please ensure that an instance is provided before calling calculate_path"
140
- end
141
-
142
- base = config[:test_base_path]
143
- candidates = []
144
- candidates << File.join(base, instance.suite.name, 'ansible', path)
145
- candidates << File.join(base, instance.suite.name, path)
146
- candidates << File.join(base, path)
147
- candidates << File.join(Dir.pwd, path)
148
- candidates << File.join(Dir.pwd) if path == 'roles'
149
-
150
- candidates.find do |c|
151
- type == :directory ? File.directory?(c) : File.file?(c)
152
- end
153
- end
154
-
155
-
156
- end
157
-
158
- end
159
- end
160
-
161
- 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
+
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, 'https://raw.githubusercontent.com/neillturner/omnibus-ansible/master/ansible_install.sh'
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 :enable_yum_epel, false
43
+ default_config :extra_vars, {}
44
+ default_config :tags, []
45
+ default_config :ansible_apt_repo, "ppa:ansible/ansible"
46
+ default_config :ansible_yum_repo, "https://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
47
+ default_config :ansible_sles_repo, "http://download.opensuse.org/repositories/systemsmanagement/SLE_12/systemsmanagement.repo"
48
+ default_config :python_sles_repo, "http://download.opensuse.org/repositories/devel:/languages:/python/SLE_12/devel:languages:python.repo"
49
+ default_config :chef_bootstrap_url, "https://www.getchef.com/chef/install.sh"
50
+ # Until we can truly make busser work without /opt/chef/embedded/bin/gem being installed, we still need Chef Omnibus
51
+ # (Reference: https://github.com/neillturner/kitchen-ansible/issues/66 )
52
+ default_config :require_chef_for_busser, true
53
+ default_config :require_ruby_for_busser, false
54
+ default_config :requirements_path, false
55
+ default_config :ansible_verbose, false
56
+ default_config :ansible_verbosity, 1
57
+ default_config :ansible_check, false
58
+ default_config :ansible_diff, false
59
+ default_config :ansible_platform, ''
60
+ default_config :ansible_connection, 'local'
61
+ default_config :update_package_repos, true
62
+ default_config :require_ansible_source, false
63
+ default_config :http_proxy, nil
64
+ default_config :https_proxy, nil
65
+ default_config :no_proxy, nil
66
+
67
+ default_config :playbook do |provisioner|
68
+ provisioner.calculate_path('default.yml', :file) or
69
+ 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"
70
+ end
71
+
72
+ default_config :roles_path do |provisioner|
73
+ provisioner.calculate_path('roles') or
74
+ raise 'No roles_path detected. Please specify one in .kitchen.yml'
75
+ end
76
+
77
+ default_config :group_vars_path do |provisioner|
78
+ provisioner.calculate_path('group_vars', :directory)
79
+ end
80
+
81
+ default_config :additional_copy_path do |provisioner|
82
+ provisioner.calculate_path('additional_copy', :directory)
83
+ end
84
+
85
+ default_config :host_vars_path do |provisioner|
86
+ provisioner.calculate_path('host_vars', :directory)
87
+ end
88
+
89
+ default_config :modules_path do |provisioner|
90
+ provisioner.calculate_path('modules', :directory)
91
+ end
92
+
93
+ default_config :ansiblefile_path do |provisioner|
94
+ provisioner.calculate_path('Ansiblefile', :file)
95
+ end
96
+
97
+ default_config :filter_plugins_path do |provisioner|
98
+ provisioner.calculate_path('filter_plugins', :directory)
99
+ end
100
+
101
+ default_config :lookup_plugins_path do |provisioner|
102
+ provisioner.calculate_path('lookup_plugins', :directory)
103
+ end
104
+
105
+ default_config :ansible_vault_password_file do |provisioner|
106
+ provisioner.calculate_path('ansible-vault-password', :file)
107
+ end
108
+
109
+ default_config :ansible_inventory_file do |provisioner|
110
+ provisioner.calculate_path('hosts', :file)
111
+ end
112
+
113
+ def initialize(config = {})
114
+ init_config(config)
115
+ end
116
+
117
+ def set_instance(instance)
118
+ @instance = instance
119
+ end
120
+
121
+ def []=(attr, val)
122
+ config[attr] = val
123
+ end
124
+
125
+ def [](attr)
126
+ config[attr]
127
+ end
128
+
129
+ def key?(k)
130
+ return config.key?(k)
131
+ end
132
+
133
+ def keys
134
+ config.keys
135
+ end
136
+
137
+ def calculate_path(path, type = :directory)
138
+
139
+ if not instance
140
+ raise "Please ensure that an instance is provided before calling calculate_path"
141
+ end
142
+
143
+ base = config[:test_base_path]
144
+ candidates = []
145
+ candidates << File.join(base, instance.suite.name, 'ansible', path)
146
+ candidates << File.join(base, instance.suite.name, path)
147
+ candidates << File.join(base, path)
148
+ candidates << File.join(Dir.pwd, path)
149
+ candidates << File.join(Dir.pwd) if path == 'roles'
150
+
151
+ candidates.find do |c|
152
+ type == :directory ? File.directory?(c) : File.file?(c)
153
+ end
154
+ end
155
+
156
+
157
+ end
158
+
159
+ end
160
+ end
161
+
162
+ 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