kitchen-ansible 0.0.23 → 0.0.24

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