kitchen-ansiblepush 0.5.1 → 0.5.2
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 +4 -4
- data/README.md +15 -15
- data/kitchen-ansiblepush.gemspec +9 -12
- data/lib/kitchen/provisioner/ansible_push.rb +16 -16
- data/lib/kitchen-ansible/chef_installation.rb +3 -5
- data/lib/kitchen-ansible/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ea32f1a6e9d8b8b8d192e5ea4de50405391d936
|
|
4
|
+
data.tar.gz: e2f57b3ea5a812781ee0080df0e44ad054ff1ff4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd94e8f964ccb215d564186b2d483e62b60b115b1eaa8ad89955bf7e4f36e822be5536b4e2d9cb78ecd15c07d1da3ab12cab679b0d5459e166ec380be6afdc84
|
|
7
|
+
data.tar.gz: d17a8d7c080cbc3fdd9e021456a12e9ddb92ed9838cf4ab2b4459c5bc0b5302e3740e5bd18429694db157906238449cad1934812c1bd1f4b3589f726efcd57dd
|
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
A test-kitchen plugin that adds the support for ansible in push mode
|
|
7
7
|
|
|
8
8
|
## Intro
|
|
9
|
-
This kitchen plugin adds ansible as a provisioner in push mode. Ansible will run from your host rather than run from guest machines.
|
|
9
|
+
This kitchen plugin adds ansible as a provisioner in push mode. Ansible will run from your host rather than run from guest machines.
|
|
10
10
|
|
|
11
11
|
## How to install
|
|
12
12
|
|
|
@@ -24,7 +24,7 @@ gem install kitchen-ansiblepush-<version>.gem
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Use Bundler
|
|
27
|
-
My
|
|
27
|
+
My preferred method is use Gemfile
|
|
28
28
|
|
|
29
29
|
```ruby
|
|
30
30
|
source "https://rubygems.org"
|
|
@@ -65,13 +65,13 @@ provisioner :
|
|
|
65
65
|
host_key_checking : false
|
|
66
66
|
generate_inv : true
|
|
67
67
|
use_instance_name : false # use short (platform) instead of instance name by default
|
|
68
|
-
idempotency_test :
|
|
68
|
+
idempotency_test : false
|
|
69
69
|
```
|
|
70
70
|
## idempotency test
|
|
71
71
|
If you want to check your code is idempotent you can use the idempotency_test. Essentially, this will run Ansible twice and check nothing changed in the next run. If something changed it will list the tasks. Note: If your using Ansible callback in your config this might conflict.
|
|
72
72
|
```yaml
|
|
73
|
-
idempotency_test:
|
|
74
|
-
fail_non_idempotent:
|
|
73
|
+
idempotency_test: true
|
|
74
|
+
fail_non_idempotent: true
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
If your running ansible V2 you need to white list the callback ``` callback_whitelist = changes``` in **ansible.cfg**
|
|
@@ -83,22 +83,22 @@ Since ansiblepush uses the host to run Ansible. you can simply specify the path
|
|
|
83
83
|
ansible_playbook_bin : /path/to/ansible-playbook
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
If you want any easy way to manage ansible version [AVM](https://github.com/ahelal/avm)
|
|
87
87
|
For further example you can check a matrix test [ansible-usermanage](https://github.com/AutomationWithAnsible/ansible-usermanage/blob/master/.kitchen.yml)
|
|
88
88
|
|
|
89
89
|
## Disable chef installation
|
|
90
|
-
By default chef is installed and serverspec stuff. if you
|
|
90
|
+
By default chef is installed and serverspec stuff. if you don't want to install
|
|
91
91
|
```yaml
|
|
92
92
|
chef_bootstrap_url: nil
|
|
93
93
|
```
|
|
94
94
|
## Instance name
|
|
95
|
-
Ansible push generates inventory dynamically you have
|
|
96
|
-
*use_instance_name*
|
|
95
|
+
Ansible push generates inventory dynamically you have multiple options to name your instance
|
|
96
|
+
*use_instance_name*
|
|
97
97
|
*custom_instance_name*
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
## Windows support
|
|
101
|
-
Kitchen ansiblepush has
|
|
101
|
+
Kitchen ansiblepush has experimental support.
|
|
102
102
|
to enable windows support you need to add the following to your .kitchen.yml
|
|
103
103
|
```yaml
|
|
104
104
|
...
|
|
@@ -128,12 +128,12 @@ vars
|
|
|
128
128
|
Gemfile
|
|
129
129
|
Gemfile.lock
|
|
130
130
|
.gitingore
|
|
131
|
-
|
|
131
|
+
test
|
|
132
132
|
\_ ansible.cfg
|
|
133
133
|
\_ integration
|
|
134
|
-
\_ server
|
|
134
|
+
\_ server
|
|
135
135
|
\_ server.yml # my play that will test something
|
|
136
|
-
\_ serverspec
|
|
136
|
+
\_ serverspec
|
|
137
137
|
\_ worker
|
|
138
138
|
\_ worker.yml # my play that will test something
|
|
139
139
|
\_ serverspec
|
|
@@ -148,5 +148,5 @@ tests
|
|
|
148
148
|
- https://github.com/knakayama/kitchen-ansiblepush-demo
|
|
149
149
|
|
|
150
150
|
## TODO
|
|
151
|
-
- Enable
|
|
152
|
-
- Tests (PRs for tests is
|
|
151
|
+
- Enable environment var ANSIBLE_CALLBACK_WHITELIST="changes" before call
|
|
152
|
+
- Tests (PRs for tests is highlight appreciated)
|
data/kitchen-ansiblepush.gemspec
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
$:.unshift File.expand_path('../lib', __FILE__)
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
4
2
|
require 'kitchen-ansible/version'
|
|
5
3
|
|
|
6
4
|
Gem::Specification.new do |gem|
|
|
7
|
-
gem.name =
|
|
5
|
+
gem.name = 'kitchen-ansiblepush'
|
|
8
6
|
gem.version = Kitchen::AnsiblePush::VERSION
|
|
9
|
-
gem.authors = [
|
|
10
|
-
gem.email = [
|
|
7
|
+
gem.authors = ['Adham Helal']
|
|
8
|
+
gem.email = ['adham.helal@gmail.com']
|
|
11
9
|
gem.licenses = ['MIT']
|
|
12
|
-
gem.homepage =
|
|
13
|
-
gem.summary =
|
|
14
|
-
candidates = Dir.glob(
|
|
10
|
+
gem.homepage = 'https://github.com/ahelal/kitchen-ansiblepush'
|
|
11
|
+
gem.summary = 'ansible provisioner for test-kitchen'
|
|
12
|
+
candidates = Dir.glob('{lib}/**/*') + ['README.md', 'kitchen-ansiblepush.gemspec', 'callback/changes.py']
|
|
15
13
|
gem.files = candidates.sort
|
|
16
14
|
gem.platform = Gem::Platform::RUBY
|
|
17
15
|
gem.require_paths = ['lib']
|
|
@@ -28,8 +26,7 @@ Supports running ansible in push mode
|
|
|
28
26
|
|
|
29
27
|
EOF
|
|
30
28
|
|
|
31
|
-
gem.add_runtime_dependency 'test-kitchen'
|
|
29
|
+
gem.add_runtime_dependency 'test-kitchen', '~> 1.4'
|
|
32
30
|
gem.add_development_dependency 'rspec'
|
|
33
31
|
gem.add_development_dependency 'pry'
|
|
34
|
-
|
|
35
|
-
end
|
|
32
|
+
end
|
|
@@ -72,7 +72,7 @@ module Kitchen
|
|
|
72
72
|
@extra_vars = '@' + extra_vars_path if extra_vars_is_valid
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
raise
|
|
75
|
+
raise "ansible extra_vars is in valid type: #{config[:extra_vars].class} value: #{config[:extra_vars]}" unless extra_vars_is_valid
|
|
76
76
|
end
|
|
77
77
|
info('Ansible push config validated')
|
|
78
78
|
@validated_config = config
|
|
@@ -80,11 +80,11 @@ module Kitchen
|
|
|
80
80
|
|
|
81
81
|
def machine_name
|
|
82
82
|
return @machine_name if defined? @machine_name
|
|
83
|
-
if config[:use_instance_name]
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
@machine_name = if config[:use_instance_name]
|
|
84
|
+
instance.name.gsub(/[<>]/, '')
|
|
85
|
+
else
|
|
86
|
+
instance.name.gsub(/[<>]/, '').split('-').drop(1).join('-')
|
|
87
|
+
end
|
|
88
88
|
debug('machine_name=' + @machine_name.to_s)
|
|
89
89
|
@machine_name
|
|
90
90
|
end
|
|
@@ -102,8 +102,8 @@ module Kitchen
|
|
|
102
102
|
options << '--ask-sudo-pass' if conf[:ask_sudo_pass]
|
|
103
103
|
options << '--ask-vault-pass' if conf[:ask_vault_pass]
|
|
104
104
|
options << "--vault-password-file=#{conf[:vault_password_file]}" if conf[:vault_password_file]
|
|
105
|
-
options << '--tags
|
|
106
|
-
options << '--skip-tags
|
|
105
|
+
options << '--tags=#{as_list_argument(conf[:tags])}' if conf[:tags]
|
|
106
|
+
options << '--skip-tags=#{as_list_argument(conf[:skip_tags])}' if conf[:skip_tags]
|
|
107
107
|
options << "--start-at-task=#{conf[:start_at_task]}" if conf[:start_at_task]
|
|
108
108
|
options << "--inventory-file=#{conf[:generate_inv_path]}" if conf[:generate_inv]
|
|
109
109
|
|
|
@@ -123,7 +123,7 @@ module Kitchen
|
|
|
123
123
|
return @command if defined? @command
|
|
124
124
|
@command = [conf[:ansible_playbook_bin]]
|
|
125
125
|
@command = (@command << options << conf[:playbook]).flatten.join(' ')
|
|
126
|
-
debug(
|
|
126
|
+
debug("Ansible push command= #{@command}")
|
|
127
127
|
@command
|
|
128
128
|
end
|
|
129
129
|
|
|
@@ -156,13 +156,12 @@ module Kitchen
|
|
|
156
156
|
def install_command
|
|
157
157
|
# Must install chef for busser and serverspec to work :(
|
|
158
158
|
info('*************** AnsiblePush install_command ***************')
|
|
159
|
-
# Test if ansible-playbook is installed and give a meaningful
|
|
160
|
-
# error message
|
|
159
|
+
# Test if ansible-playbook is installed and give a meaningful error message
|
|
161
160
|
version_check = command + ' --version'
|
|
162
|
-
|
|
161
|
+
_, stdout, stderr, wait_thr = Open3.popen3(command_env, version_check)
|
|
163
162
|
exit_status = wait_thr.value
|
|
164
163
|
|
|
165
|
-
raise "
|
|
164
|
+
raise "#{version_check} returned a non zero '#{exit_status}' stdout : #{stdout}, stderr: #{stderr}" unless exit_status.success?
|
|
166
165
|
|
|
167
166
|
omnibus_download_dir = conf[:omnibus_cachier] ? '/tmp/vagrant-cache/omnibus_chef' : '/tmp'
|
|
168
167
|
chef_installation(conf[:chef_bootstrap_url], omnibus_download_dir, nil)
|
|
@@ -174,7 +173,7 @@ module Kitchen
|
|
|
174
173
|
scripts << Util.shell_helpers
|
|
175
174
|
scripts << chef_installation_script(chef_url, omnibus_download_dir, transport)
|
|
176
175
|
<<-INSTALL
|
|
177
|
-
sh -c
|
|
176
|
+
sh -c "#{scripts.join('\n')}"
|
|
178
177
|
INSTALL
|
|
179
178
|
else
|
|
180
179
|
true_command
|
|
@@ -194,6 +193,7 @@ module Kitchen
|
|
|
194
193
|
'PLUGIN_CHANGES_FILE' => file_path
|
|
195
194
|
), command, 'ansible-playbook'
|
|
196
195
|
)
|
|
196
|
+
debug("idempotency file #{file_path}")
|
|
197
197
|
# Check ansible callback if changes has occured in the second run
|
|
198
198
|
if File.file?(file_path)
|
|
199
199
|
task = 0
|
|
@@ -222,12 +222,12 @@ module Kitchen
|
|
|
222
222
|
protected
|
|
223
223
|
|
|
224
224
|
def exec_ansible_command(env, command, desc)
|
|
225
|
-
debug(
|
|
225
|
+
debug("env=#{env} command=#{command}")
|
|
226
226
|
system(env, command.to_s)
|
|
227
227
|
exit_code = $CHILD_STATUS.exitstatus
|
|
228
228
|
debug("ansible-playbook exit code = #{exit_code}")
|
|
229
229
|
if exit_code.to_i != 0
|
|
230
|
-
raise
|
|
230
|
+
raise "#{desc} returned a non zero #{exit_code}. Please see the output above."
|
|
231
231
|
end
|
|
232
232
|
end
|
|
233
233
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
def chef_installation_script(chef_url, omnibus_download_dir
|
|
2
|
+
def chef_installation_script(chef_url, omnibus_download_dir)
|
|
3
3
|
<<-INSTALL
|
|
4
|
-
if [ ! -d "/opt/chef" ]
|
|
5
|
-
then
|
|
4
|
+
if [ ! -d "/opt/chef" ]; then
|
|
6
5
|
echo "-----> Installing Chef Omnibus needed by busser and serverspec"
|
|
7
6
|
mkdir -p #{omnibus_download_dir}
|
|
8
|
-
if [ ! -x #{omnibus_download_dir}/install.sh ]
|
|
9
|
-
then
|
|
7
|
+
if [ ! -x #{omnibus_download_dir}/install.sh ]; then
|
|
10
8
|
do_download #{chef_url} #{omnibus_download_dir}/install.sh
|
|
11
9
|
fi
|
|
12
10
|
sudo sh #{omnibus_download_dir}/install.sh -d #{omnibus_download_dir}
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-ansiblepush
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adham Helal
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-12-
|
|
11
|
+
date: 2016-12-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '1.4'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '1.4'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rspec
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|