kitchen-ansible 0.48.6 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +270 -269
- data/kitchen-ansible.gemspec +35 -35
- data/lib/kitchen/provisioner/ansible/config.rb +197 -195
- data/lib/kitchen/provisioner/ansible/librarian.rb +78 -78
- data/lib/kitchen/provisioner/ansible/os/alpine.rb +42 -42
- data/lib/kitchen/provisioner/ansible/os/amazon.rb +42 -42
- data/lib/kitchen/provisioner/ansible/os/darwin.rb +37 -37
- data/lib/kitchen/provisioner/ansible/os/debian.rb +75 -75
- data/lib/kitchen/provisioner/ansible/os/fedora.rb +60 -60
- data/lib/kitchen/provisioner/ansible/os/freebsd.rb +34 -0
- data/lib/kitchen/provisioner/ansible/os/openbsd.rb +36 -36
- data/lib/kitchen/provisioner/ansible/os/redhat.rb +80 -80
- data/lib/kitchen/provisioner/ansible/os/suse.rb +44 -44
- data/lib/kitchen/provisioner/ansible/os.rb +84 -81
- data/lib/kitchen/provisioner/ansible_playbook.rb +1239 -1221
- data/lib/kitchen-ansible/version.rb +6 -6
- data/provisioner_options.md +268 -266
- metadata +4 -3
|
@@ -1,195 +1,197 @@
|
|
|
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 :extra_vars_file, nil
|
|
43
|
-
default_config :env_vars, {}
|
|
44
|
-
default_config :tags, []
|
|
45
|
-
default_config :ansible_apt_repo, 'ppa:ansible/ansible'
|
|
46
|
-
default_config :ansible_yum_repo, nil
|
|
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.chef.io/chef/install.sh'
|
|
50
|
-
# Providing we have Ruby >= 2.0 we only need Ruby. Leaving default to install Chef Omnibus for backwards compatibility.
|
|
51
|
-
# Note: if using kitchen-verifer-serverspec your we can avoid needing Ruby too.
|
|
52
|
-
# (Reference: https://github.com/neillturner/kitchen-ansible/issues/66 )
|
|
53
|
-
default_config :require_chef_for_busser, true
|
|
54
|
-
default_config :require_ruby_for_busser, false
|
|
55
|
-
default_config :require_windows_support, false
|
|
56
|
-
default_config :require_pip, false
|
|
57
|
-
default_config :requirements_path, false
|
|
58
|
-
default_config :ssh_known_hosts, nil
|
|
59
|
-
default_config :additional_ssh_private_keys, nil
|
|
60
|
-
default_config :ansible_verbose, false
|
|
61
|
-
default_config :ansible_verbosity, 1
|
|
62
|
-
default_config :ansible_check, false
|
|
63
|
-
default_config :ansible_diff, false
|
|
64
|
-
default_config :ansible_platform, ''
|
|
65
|
-
default_config :ansible_connection, 'local'
|
|
66
|
-
default_config :update_package_repos, true
|
|
67
|
-
default_config :require_ansible_source, false
|
|
68
|
-
default_config :ansible_source_url, 'git://github.com/ansible/ansible.git'
|
|
69
|
-
default_config :ansible_source_rev, nil
|
|
70
|
-
default_config :http_proxy, nil
|
|
71
|
-
default_config :https_proxy, nil
|
|
72
|
-
default_config :no_proxy, nil
|
|
73
|
-
default_config :ansible_playbook_command, nil
|
|
74
|
-
default_config :ansible_host_key_checking, true
|
|
75
|
-
default_config :idempotency_test, nil
|
|
76
|
-
default_config :idempotency_tags, []
|
|
77
|
-
default_config :idempotency_skip_tags, []
|
|
78
|
-
default_config :ansible_inventory, nil
|
|
79
|
-
default_config :ansible_inventory_file, nil
|
|
80
|
-
default_config :ansible_limit, nil
|
|
81
|
-
default_config :ignore_extensions_from_root, ['.pyc']
|
|
82
|
-
default_config :ignore_paths_from_root, []
|
|
83
|
-
default_config :role_name, nil
|
|
84
|
-
default_config :additional_copy_role_path, false
|
|
85
|
-
default_config :shell_command, 'sh'
|
|
86
|
-
default_config :custom_pre_install_command, nil
|
|
87
|
-
default_config :custom_pre_play_command, nil
|
|
88
|
-
default_config :custom_post_install_command, nil
|
|
89
|
-
default_config :custom_post_play_command, nil
|
|
90
|
-
default_config :show_command_output, false
|
|
91
|
-
default_config :ignore_ansible_cfg, false
|
|
92
|
-
|
|
93
|
-
default_config :
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
candidates
|
|
184
|
-
candidates << File.join(base, path)
|
|
185
|
-
candidates << File.join(
|
|
186
|
-
candidates << File.join(
|
|
187
|
-
|
|
188
|
-
candidates.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
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 :extra_vars_file, nil
|
|
43
|
+
default_config :env_vars, {}
|
|
44
|
+
default_config :tags, []
|
|
45
|
+
default_config :ansible_apt_repo, 'ppa:ansible/ansible'
|
|
46
|
+
default_config :ansible_yum_repo, nil
|
|
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.chef.io/chef/install.sh'
|
|
50
|
+
# Providing we have Ruby >= 2.0 we only need Ruby. Leaving default to install Chef Omnibus for backwards compatibility.
|
|
51
|
+
# Note: if using kitchen-verifer-serverspec your we can avoid needing Ruby too.
|
|
52
|
+
# (Reference: https://github.com/neillturner/kitchen-ansible/issues/66 )
|
|
53
|
+
default_config :require_chef_for_busser, true
|
|
54
|
+
default_config :require_ruby_for_busser, false
|
|
55
|
+
default_config :require_windows_support, false
|
|
56
|
+
default_config :require_pip, false
|
|
57
|
+
default_config :requirements_path, false
|
|
58
|
+
default_config :ssh_known_hosts, nil
|
|
59
|
+
default_config :additional_ssh_private_keys, nil
|
|
60
|
+
default_config :ansible_verbose, false
|
|
61
|
+
default_config :ansible_verbosity, 1
|
|
62
|
+
default_config :ansible_check, false
|
|
63
|
+
default_config :ansible_diff, false
|
|
64
|
+
default_config :ansible_platform, ''
|
|
65
|
+
default_config :ansible_connection, 'local'
|
|
66
|
+
default_config :update_package_repos, true
|
|
67
|
+
default_config :require_ansible_source, false
|
|
68
|
+
default_config :ansible_source_url, 'git://github.com/ansible/ansible.git'
|
|
69
|
+
default_config :ansible_source_rev, nil
|
|
70
|
+
default_config :http_proxy, nil
|
|
71
|
+
default_config :https_proxy, nil
|
|
72
|
+
default_config :no_proxy, nil
|
|
73
|
+
default_config :ansible_playbook_command, nil
|
|
74
|
+
default_config :ansible_host_key_checking, true
|
|
75
|
+
default_config :idempotency_test, nil
|
|
76
|
+
default_config :idempotency_tags, []
|
|
77
|
+
default_config :idempotency_skip_tags, []
|
|
78
|
+
default_config :ansible_inventory, nil
|
|
79
|
+
default_config :ansible_inventory_file, nil
|
|
80
|
+
default_config :ansible_limit, nil
|
|
81
|
+
default_config :ignore_extensions_from_root, ['.pyc']
|
|
82
|
+
default_config :ignore_paths_from_root, []
|
|
83
|
+
default_config :role_name, nil
|
|
84
|
+
default_config :additional_copy_role_path, false
|
|
85
|
+
default_config :shell_command, 'sh'
|
|
86
|
+
default_config :custom_pre_install_command, nil
|
|
87
|
+
default_config :custom_pre_play_command, nil
|
|
88
|
+
default_config :custom_post_install_command, nil
|
|
89
|
+
default_config :custom_post_play_command, nil
|
|
90
|
+
default_config :show_command_output, false
|
|
91
|
+
default_config :ignore_ansible_cfg, false
|
|
92
|
+
default_config :galaxy_ignore_certs, false
|
|
93
|
+
default_config :keep_playbook_path, false
|
|
94
|
+
|
|
95
|
+
default_config :playbook do |provisioner|
|
|
96
|
+
provisioner.calculate_path('default.yml', :file) ||
|
|
97
|
+
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')
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
default_config :roles_path do |provisioner|
|
|
101
|
+
provisioner.calculate_path('roles') ||
|
|
102
|
+
fail('No roles_path detected. Please specify one in .kitchen.yml')
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
default_config :group_vars_path do |provisioner|
|
|
106
|
+
provisioner.calculate_path('group_vars', :directory)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
default_config :additional_copy_path do |provisioner|
|
|
110
|
+
provisioner.calculate_path('additional_copy', :directory)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
default_config :recursive_additional_copy_path do |provisioner|
|
|
114
|
+
provisioner.calculate_path('recursive_additional_copy', :directory)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
default_config :host_vars_path do |provisioner|
|
|
118
|
+
provisioner.calculate_path('host_vars', :directory)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
default_config :modules_path do |provisioner|
|
|
122
|
+
provisioner.calculate_path('modules', :directory)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
default_config :ansiblefile_path do |provisioner|
|
|
126
|
+
provisioner.calculate_path('Ansiblefile', :file)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
default_config :library_plugins_path do |provisioner|
|
|
130
|
+
provisioner.calculate_path('library', :directory)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
default_config :callback_plugins_path do |provisioner|
|
|
134
|
+
provisioner.calculate_path('callback_plugins', :directory)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
default_config :filter_plugins_path do |provisioner|
|
|
138
|
+
provisioner.calculate_path('filter_plugins', :directory)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
default_config :lookup_plugins_path do |provisioner|
|
|
142
|
+
provisioner.calculate_path('lookup_plugins', :directory)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
default_config :ansible_vault_password_file do |provisioner|
|
|
146
|
+
provisioner.calculate_path('ansible-vault-password', :file)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
default_config :kerberos_conf_file do |provisioner|
|
|
150
|
+
provisioner.calculate_path('kerberos_conf', :file)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
default_config :ansible_cfg_path do |provisioner|
|
|
154
|
+
provisioner.calculate_path('ansible.cfg', :file)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def initialize(config = {})
|
|
158
|
+
init_config(config)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def []=(attr, val)
|
|
162
|
+
config[attr] = val
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def [](attr)
|
|
166
|
+
config[attr]
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def key?(k)
|
|
170
|
+
config.key?(k)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def keys
|
|
174
|
+
config.keys
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def calculate_path(path, type = :directory)
|
|
178
|
+
unless instance
|
|
179
|
+
fail 'Please ensure that an instance is provided before calling calculate_path'
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
base = config[:test_base_path]
|
|
183
|
+
candidates = []
|
|
184
|
+
candidates << File.join(base, instance.suite.name, 'ansible', path)
|
|
185
|
+
candidates << File.join(base, instance.suite.name, path)
|
|
186
|
+
candidates << File.join(base, path)
|
|
187
|
+
candidates << File.join(Dir.pwd, path)
|
|
188
|
+
candidates << File.join(Dir.pwd) if path == 'roles'
|
|
189
|
+
|
|
190
|
+
candidates.find do |c|
|
|
191
|
+
type == :directory ? File.directory?(c) : File.file?(c)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
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
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Author:: Martin Etmajer (<martin@etmajer.com>)
|
|
4
|
-
#
|
|
5
|
-
# Copyright (C) 2016 Martin Etmajer
|
|
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
|
-
module Kitchen
|
|
21
|
-
module Provisioner
|
|
22
|
-
module Ansible
|
|
23
|
-
class Os
|
|
24
|
-
class Alpine < Os
|
|
25
|
-
def update_packages_command
|
|
26
|
-
@config[:update_package_repos] ? "#{sudo_env('apk')} update" : nil
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def install_command
|
|
30
|
-
<<-INSTALL
|
|
31
|
-
|
|
32
|
-
if [ ! $(which ansible) ]; then
|
|
33
|
-
#{update_packages_command}
|
|
34
|
-
#{sudo_env('apk')} add ansible git
|
|
35
|
-
fi
|
|
36
|
-
INSTALL
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Author:: Martin Etmajer (<martin@etmajer.com>)
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2016 Martin Etmajer
|
|
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
|
+
module Kitchen
|
|
21
|
+
module Provisioner
|
|
22
|
+
module Ansible
|
|
23
|
+
class Os
|
|
24
|
+
class Alpine < Os
|
|
25
|
+
def update_packages_command
|
|
26
|
+
@config[:update_package_repos] ? "#{sudo_env('apk')} update" : nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def install_command
|
|
30
|
+
<<-INSTALL
|
|
31
|
+
|
|
32
|
+
if [ ! $(which ansible) ]; then
|
|
33
|
+
#{update_packages_command}
|
|
34
|
+
#{sudo_env('apk')} add ansible git
|
|
35
|
+
fi
|
|
36
|
+
INSTALL
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|