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.
@@ -1,5 +1,5 @@
1
- module Kitchen
2
- module Ansible
3
- VERSION = "0.0.21"
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 :ansible_verbose, false
36
- default_config :require_ansible_omnibus, false
37
- default_config :ansible_omnibus_url, nil
38
- default_config :ansible_omnibus_remote_path, '/opt/ansible'
39
- default_config :ansible_version, nil
40
- default_config :require_ansible_repo, true
41
- default_config :extra_vars, {}
42
- default_config :tags, []
43
- default_config :ansible_apt_repo, "ppa:ansible/ansible"
44
- default_config :ansible_yum_repo, "https://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
45
- default_config :chef_bootstrap_url, "https://www.getchef.com/chef/install.sh"
46
- default_config :require_chef_for_busser, false
47
- default_config :require_ruby_for_busser, true
48
- default_config :requirements_path, false
49
- default_config :ansible_verbose, false
50
- default_config :ansible_verbosity, 1
51
- default_config :ansible_check, false
52
- default_config :ansible_diff, false
53
- default_config :ansible_platform, ''
54
- default_config :ansible_connection, 'local'
55
- default_config :update_package_repos, true
56
- default_config :require_ansible_source, false
57
-
58
- default_config :playbook do |provisioner|
59
- provisioner.calculate_path('default.yml', :file) or
60
- 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"
61
- end
62
-
63
- default_config :roles_path do |provisioner|
64
- provisioner.calculate_path('roles') or
65
- raise 'No roles_path detected. Please specify one in .kitchen.yml'
66
- end
67
-
68
- default_config :group_vars_path do |provisioner|
69
- provisioner.calculate_path('group_vars', :directory)
70
- end
71
-
72
- default_config :additional_copy_path do |provisioner|
73
- provisioner.calculate_path('additional_copy', :directory)
74
- end
75
-
76
- default_config :host_vars_path do |provisioner|
77
- provisioner.calculate_path('host_vars', :directory)
78
- end
79
-
80
- default_config :modules_path do |provisioner|
81
- provisioner.calculate_path('modules', :directory)
82
- end
83
-
84
- default_config :ansiblefile_path do |provisioner|
85
- provisioner.calculate_path('Ansiblefile', :file)
86
- end
87
-
88
- default_config :filter_plugins_path do |provisioner|
89
- provisioner.calculate_path('filter_plugins', :directory)
90
- end
91
-
92
- default_config :ansible_vault_password_file do |provisioner|
93
- provisioner.calculate_path('ansible-vault-password', :file)
94
- end
95
-
96
- default_config :ansible_inventory_file do |provisioner|
97
- provisioner.calculate_path('hosts', :file)
98
- end
99
-
100
- def initialize(config = {})
101
- init_config(config)
102
- end
103
-
104
- def set_instance(instance)
105
- @instance = instance
106
- end
107
-
108
- def []=(attr, val)
109
- config[attr] = val
110
- end
111
-
112
- def [](attr)
113
- config[attr]
114
- end
115
-
116
- def key?(k)
117
- return config.key?(k)
118
- end
119
-
120
- def keys
121
- config.keys
122
- end
123
-
124
- def calculate_path(path, type = :directory)
125
-
126
- if not instance
127
- raise "Please ensure that an instance is provided before calling calculate_path"
128
- end
129
-
130
- base = config[:test_base_path]
131
- candidates = []
132
- candidates << File.join(base, instance.suite.name, 'ansible', path)
133
- candidates << File.join(base, instance.suite.name, path)
134
- candidates << File.join(base, path)
135
- candidates << File.join(Dir.pwd, path)
136
- candidates << File.join(Dir.pwd) if path == 'roles'
137
-
138
- candidates.find do |c|
139
- type == :directory ? File.directory?(c) : File.file?(c)
140
- end
141
- end
142
-
143
-
144
- end
145
-
146
- end
147
- end
148
-
149
- 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 :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