kitchen-ansible 0.0.22 → 0.0.23

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.22"
4
- end
5
- end
1
+ module Kitchen
2
+ module Ansible
3
+ VERSION = "0.0.23"
4
+ end
5
+ end
@@ -1,150 +1,156 @@
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
+ # -*- 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,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