kitchen-ansible 0.46.0 → 0.46.1
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b32daee00e5d86149852730c2886d4e57b5324d4
|
|
4
|
+
data.tar.gz: 60b860dff81e09a2e571903bcf659b6b0bf3b141
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58da2f4aad784bed8f6a88ee035bcbfb25ce1305b0e8bca7e68eee0b6eb3d8514924f151043a4105ecca164051e0350980a73e942984f693a85e312cd3b436e5
|
|
7
|
+
data.tar.gz: 31a20f6821e86b2d69acb4185947e48b162e1bdfd6d1351b1c60789dac6b9c0b2ee8edcdf1534c273b4559f380c7c27626da7a61c6e118d1ee3d4e6e684dd1a3
|
|
@@ -80,6 +80,10 @@ module Kitchen
|
|
|
80
80
|
default_config :role_name, nil
|
|
81
81
|
default_config :additional_copy_role_path, false
|
|
82
82
|
default_config :shell_command, 'sh'
|
|
83
|
+
default_config :custom_pre_install_command, nil
|
|
84
|
+
default_config :custom_pre_play_command, nil
|
|
85
|
+
default_config :custom_post_install_command, nil
|
|
86
|
+
default_config :custom_post_play_command, nil
|
|
83
87
|
|
|
84
88
|
default_config :playbook do |provisioner|
|
|
85
89
|
provisioner.calculate_path('default.yml', :file) ||
|
|
@@ -106,7 +106,8 @@ module Kitchen
|
|
|
106
106
|
else
|
|
107
107
|
return
|
|
108
108
|
end
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
result = custom_pre_install_command + cmd + install_windows_support + install_busser_prereqs + custom_post_install_command
|
|
110
111
|
debug("Going to install ansible with: #{result}")
|
|
111
112
|
result
|
|
112
113
|
end
|
|
@@ -234,6 +235,19 @@ module Kitchen
|
|
|
234
235
|
install
|
|
235
236
|
end
|
|
236
237
|
|
|
238
|
+
def custom_pre_install_command
|
|
239
|
+
<<-INSTALL
|
|
240
|
+
|
|
241
|
+
#{config[:custom_pre_install_command]}
|
|
242
|
+
INSTALL
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def custom_post_install_command
|
|
246
|
+
<<-INSTALL
|
|
247
|
+
#{config[:custom_post_install_command]}
|
|
248
|
+
INSTALL
|
|
249
|
+
end
|
|
250
|
+
|
|
237
251
|
def init_command
|
|
238
252
|
dirs = %w(modules roles group_vars host_vars)
|
|
239
253
|
.map { |dir| File.join(config[:root_path], dir) }.join(' ')
|
|
@@ -346,53 +360,64 @@ module Kitchen
|
|
|
346
360
|
end
|
|
347
361
|
|
|
348
362
|
def run_command
|
|
349
|
-
|
|
350
|
-
|
|
363
|
+
return config[:ansible_playbook_command] unless config[:ansible_playbook_command].nil?
|
|
364
|
+
if config[:require_ansible_source] && !config[:ansible_binary_path]
|
|
365
|
+
# this is an ugly hack to get around the fact that extra vars uses ' and "
|
|
366
|
+
cmd = ansible_command("PATH=#{config[:root_path]}/ansible/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PYTHONPATH=#{config[:root_path]}/ansible/lib MANPATH=#{config[:root_path]}/ansible/docs/man ansible-playbook")
|
|
367
|
+
elsif config[:ansible_binary_path]
|
|
368
|
+
cmd = ansible_command("#{config[:ansible_binary_path]}/ansible-playbook")
|
|
351
369
|
else
|
|
370
|
+
cmd = ansible_command('ansible-playbook')
|
|
371
|
+
end
|
|
352
372
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
373
|
+
cmd = "#{env_vars} #{cmd}" if !config[:env_vars].none?
|
|
374
|
+
cmd = "HTTPS_PROXY=#{https_proxy} #{cmd}" if https_proxy
|
|
375
|
+
cmd = "HTTP_PROXY=#{http_proxy} #{cmd}" if http_proxy
|
|
376
|
+
cmd = "NO_PROXY=#{no_proxy} #{cmd}" if no_proxy
|
|
377
|
+
cmd = "ANSIBLE_ROLES_PATH=#{ansible_roles_path} #{cmd}" if ansible_roles_path
|
|
378
|
+
cmd = "ANSIBLE_HOST_KEY_CHECKING=false #{cmd}" if !ansible_host_key_checking
|
|
379
|
+
|
|
380
|
+
cmd = "#{cd_ansible} #{cmd}" if !config[:ansible_sudo].nil? && !config[:ansible_sudo]
|
|
381
|
+
cmd = "#{copy_private_key_cmd} #{cmd}" if config[:private_key]
|
|
382
|
+
|
|
383
|
+
result = [
|
|
384
|
+
cmd,
|
|
385
|
+
ansible_inventory_flag,
|
|
386
|
+
ansible_limit_flag,
|
|
387
|
+
ansible_connection_flag,
|
|
388
|
+
"-M #{File.join(config[:root_path], 'modules')}",
|
|
389
|
+
ansible_verbose_flag,
|
|
390
|
+
ansible_check_flag,
|
|
391
|
+
ansible_diff_flag,
|
|
392
|
+
ansible_vault_flag,
|
|
393
|
+
private_key,
|
|
394
|
+
extra_vars,
|
|
395
|
+
extra_vars_file,
|
|
396
|
+
tags,
|
|
397
|
+
ansible_extra_flags,
|
|
398
|
+
"#{File.join(config[:root_path], File.basename(config[:playbook]))}"
|
|
399
|
+
].join(' ')
|
|
400
|
+
if config[:custom_post_play_command]
|
|
401
|
+
custom_post_play_trap = <<-TRAP
|
|
402
|
+
function custom_post_play_command {
|
|
403
|
+
#{config[:custom_post_play_command]}
|
|
404
|
+
}
|
|
405
|
+
trap custom_post_play_command EXIT
|
|
406
|
+
TRAP
|
|
407
|
+
end
|
|
408
|
+
result = <<-RUN
|
|
409
|
+
#{config[:custom_pre_play_command]}
|
|
410
|
+
#{custom_post_play_trap}
|
|
411
|
+
#{result}
|
|
412
|
+
RUN
|
|
413
|
+
debug("Going to invoke ansible-playbook with: #{result}")
|
|
414
|
+
if config[:idempotency_test]
|
|
415
|
+
result = "#{result} && (echo 'Going to invoke ansible-playbook second time:'; #{result} | tee /tmp/idempotency_test.txt; grep -q 'changed=0.*failed=0' /tmp/idempotency_test.txt && (echo 'Idempotence test: PASS' && exit 0) || (echo 'Idempotence test: FAIL' && exit 1))"
|
|
416
|
+
debug("Full cmd with idempotency test: #{result}")
|
|
417
|
+
end
|
|
361
418
|
|
|
362
|
-
|
|
363
|
-
cmd = "HTTPS_PROXY=#{https_proxy} #{cmd}" if https_proxy
|
|
364
|
-
cmd = "HTTP_PROXY=#{http_proxy} #{cmd}" if http_proxy
|
|
365
|
-
cmd = "NO_PROXY=#{no_proxy} #{cmd}" if no_proxy
|
|
366
|
-
cmd = "ANSIBLE_ROLES_PATH=#{ansible_roles_path} #{cmd}" if ansible_roles_path
|
|
367
|
-
cmd = "ANSIBLE_HOST_KEY_CHECKING=false #{cmd}" if !ansible_host_key_checking
|
|
368
|
-
|
|
369
|
-
cmd = "#{cd_ansible} #{cmd}" if !config[:ansible_sudo].nil? && !config[:ansible_sudo]
|
|
370
|
-
cmd = "#{copy_private_key_cmd} #{cmd}" if config[:private_key]
|
|
371
|
-
|
|
372
|
-
result = [
|
|
373
|
-
cmd,
|
|
374
|
-
ansible_inventory_flag,
|
|
375
|
-
ansible_limit_flag,
|
|
376
|
-
ansible_connection_flag,
|
|
377
|
-
"-M #{File.join(config[:root_path], 'modules')}",
|
|
378
|
-
ansible_verbose_flag,
|
|
379
|
-
ansible_check_flag,
|
|
380
|
-
ansible_diff_flag,
|
|
381
|
-
ansible_vault_flag,
|
|
382
|
-
private_key,
|
|
383
|
-
extra_vars,
|
|
384
|
-
tags,
|
|
385
|
-
ansible_extra_flags,
|
|
386
|
-
"#{File.join(config[:root_path], File.basename(config[:playbook]))}"
|
|
387
|
-
].join(' ')
|
|
388
|
-
debug("Going to invoke ansible-playbook with: #{result}")
|
|
389
|
-
if config[:idempotency_test]
|
|
390
|
-
result = "#{result} && (echo 'Going to invoke ansible-playbook second time:'; #{result} | tee /tmp/idempotency_test.txt; grep -q 'changed=0.*failed=0' /tmp/idempotency_test.txt && (echo 'Idempotence test: PASS' && exit 0) || (echo 'Idempotence test: FAIL' && exit 1))"
|
|
391
|
-
debug("Full cmd with idempotency test: #{result}")
|
|
392
|
-
end
|
|
419
|
+
result
|
|
393
420
|
|
|
394
|
-
result
|
|
395
|
-
end
|
|
396
421
|
end
|
|
397
422
|
|
|
398
423
|
def ansible_command(script)
|
|
@@ -747,13 +772,16 @@ module Kitchen
|
|
|
747
772
|
bash_vars = config[:attributes][:extra_vars]
|
|
748
773
|
end
|
|
749
774
|
|
|
750
|
-
return nil if bash_vars.none?
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
775
|
+
return nil if bash_vars.none?
|
|
776
|
+
bash_vars = JSON.dump(bash_vars)
|
|
777
|
+
bash_vars = "-e '#{bash_vars}'"
|
|
778
|
+
debug(bash_vars)
|
|
779
|
+
bash_vars
|
|
780
|
+
end
|
|
781
|
+
|
|
782
|
+
def extra_vars_file
|
|
783
|
+
return nil if config[:extra_vars_file].nil?
|
|
784
|
+
bash_extra_vars = "-e '\@#{config[:extra_vars_file]}'"
|
|
757
785
|
debug(bash_extra_vars)
|
|
758
786
|
bash_extra_vars
|
|
759
787
|
end
|
data/provisioner_options.md
CHANGED
|
@@ -54,10 +54,14 @@ ansible_yum_repo | nil | `yum` repo for EL platforms
|
|
|
54
54
|
ansiblefile_path | | Path to Ansiblefile
|
|
55
55
|
callback_plugins_path | callback_plugins | Ansible repo `callback_plugins` directory
|
|
56
56
|
chef_bootstrap_url | `https://www.getchef.com/chef/install.sh` | The Chef install
|
|
57
|
+
custom_pre_install_command | nil | Custom shell command to be used at beginning of install stage. Can be multiline.
|
|
58
|
+
custom_pre_play_command | nil | Custom shell command to be used before the ansible play stage. Can be multiline. See examples below.
|
|
59
|
+
custom_post_install_command | nil | Custom shell command to be used at after the install stage. Can be multiline.
|
|
60
|
+
custom_post_play_command | nil | Custom shell command to be used after the ansible play stage. Can be multiline. See examples below.
|
|
57
61
|
enable_yum_epel | false | Enable the `yum` EPEL repo
|
|
58
62
|
env_vars | Hash.new | Hash to set environment variable to use with `ansible-playbook` command
|
|
59
63
|
extra_vars | Hash.new | Hash to set the `extra_vars` passed to `ansible-playbook` command
|
|
60
|
-
extra_vars_file | nil | file containing environment variables e.g. `private_vars/production.yml site.yml`
|
|
64
|
+
extra_vars_file | nil | file containing environment variables e.g. `private_vars/production.yml site.yml` Don't prefix with a @ sign.
|
|
61
65
|
filter_plugins_path | filter_plugins | Ansible repo `filter_plugins` directory
|
|
62
66
|
group_vars_path | group_vars | Ansible repo group_vars directory
|
|
63
67
|
host_vars_path | host_vars | Ansible repo hosts directory
|
|
@@ -132,3 +136,15 @@ $kitchen_root/ansible/$suite_name/roles
|
|
|
132
136
|
$kitchen_root/ansible/$suite_name/modules
|
|
133
137
|
$kitchen_root/ansible/$suite_name/Ansiblefile
|
|
134
138
|
```
|
|
139
|
+
|
|
140
|
+
Multiple Line Structure
|
|
141
|
+
```yaml
|
|
142
|
+
provisioner::
|
|
143
|
+
command: |
|
|
144
|
+
sudo -s <<SERVERSPEC
|
|
145
|
+
cd /opt/gdc/serverspec-core
|
|
146
|
+
export SERVERSPEC_ENV=$EC2DATA_ENVIRONMENT
|
|
147
|
+
export SERVERSPEC_BACKEND=exec
|
|
148
|
+
serverspec junit=true tag=~skip_in_kitchen check:role:$EC2DATA_TYPE
|
|
149
|
+
SERVERSPEC
|
|
150
|
+
```
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-ansible
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.46.
|
|
4
|
+
version: 0.46.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Neill Turner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-03-
|
|
11
|
+
date: 2017-03-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|