kitchen-ansiblepush 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -9
- data/lib/kitchen/provisioner/ansible_push.rb +23 -7
- data/lib/kitchen-ansible/util_inventory.rb +8 -2
- data/lib/kitchen-ansible/version.rb +1 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7b7a7c54d6db3032fafdec0df791c8c5218917b
|
4
|
+
data.tar.gz: 06cd24f0c08c3960d6b718ae92e2baa52b816efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f27af40952e7f1a8e6a284972c92e211e3795de71167e94a6c68d0eb599cfac822b21cfb24cf2236e9ba6210516a3d8522279dd5dc08192d11bcb3ec1b446122
|
7
|
+
data.tar.gz: 7d1186dcd96c12611a20f91e62c7a96454c462d37d817cd4c849ff053db4ec3ee4b9c490d763a6843d15397f4d2b317bd14d68670da65be02175e061e9b83bf3
|
data/README.md
CHANGED
@@ -8,23 +8,23 @@ A test-kitchen plugin that adds the support for ansible in push mode
|
|
8
8
|
## Intro
|
9
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
|
-
## How to install
|
11
|
+
## How to install
|
12
12
|
|
13
13
|
### Ruby gem
|
14
14
|
```
|
15
15
|
gem install kitchen-ansiblepush
|
16
16
|
```
|
17
17
|
|
18
|
-
### To install from code
|
19
|
-
```
|
18
|
+
### To install from code
|
19
|
+
```
|
20
20
|
git clone git@github.com:ahelal/kitchen-ansiblepush.git
|
21
21
|
cd kitchen-ansiblepush
|
22
22
|
gem build kitchen-ansiblepush.gemspec
|
23
23
|
gem install kitchen-ansiblepush-<version>.gem
|
24
24
|
```
|
25
25
|
|
26
|
-
### Use Bundler
|
27
|
-
My prefered method is use Gemfile
|
26
|
+
### Use Bundler
|
27
|
+
My prefered method is use Gemfile
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
source "https://rubygems.org"
|
@@ -53,7 +53,7 @@ provisioner :
|
|
53
53
|
skip_tags : [ "notme", "orme" ]
|
54
54
|
start_at_task : [ "five" ]
|
55
55
|
# Hash of other groups
|
56
|
-
groups :
|
56
|
+
groups :
|
57
57
|
db :
|
58
58
|
- db01
|
59
59
|
sudo : true
|
@@ -87,11 +87,30 @@ You can use venv and install multi version of ansible or if you prefer you can u
|
|
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 dont want to install
|
90
|
+
By default chef is installed and serverspec stuff. if you dont want to install
|
91
91
|
```yaml
|
92
92
|
chef_bootstrap_url: nil
|
93
93
|
```
|
94
|
+
## Instance name
|
95
|
+
Ansible push generates inventory dynamically you have multipule options to name your instance
|
96
|
+
*use_instance_name*
|
97
|
+
*custom_instance_name*
|
98
|
+
|
94
99
|
|
100
|
+
## Windows support
|
101
|
+
Kitchen ansiblepush has experimantal support.
|
102
|
+
to enable windows support you need to add the following to your .kitchen.yml
|
103
|
+
```yaml
|
104
|
+
...
|
105
|
+
transport:
|
106
|
+
name: winrm
|
107
|
+
winrm_transport: negotiate
|
108
|
+
provisioner:
|
109
|
+
name : ansible_push
|
110
|
+
chef_bootstrap_url : nil
|
111
|
+
ansible_connection : "winrm"
|
112
|
+
...
|
113
|
+
```
|
95
114
|
## Pattern of usage
|
96
115
|
You can use ansible push with different pattern. I will list some of the ways that I use it, But by no means they are the only patterns.
|
97
116
|
### Roles
|
@@ -131,5 +150,3 @@ tests
|
|
131
150
|
## TODO
|
132
151
|
- Enable envirionment var ANSIBLE_CALLBACK_WHITELIST="changes" before call
|
133
152
|
- Tests (PRs for tests is highligh appreciated)
|
134
|
-
|
135
|
-
|
@@ -41,6 +41,7 @@ module Kitchen
|
|
41
41
|
default_config :idempotency_test, false
|
42
42
|
default_config :fail_non_idempotent, true
|
43
43
|
default_config :use_instance_name, false
|
44
|
+
default_config :ansible_connection, "smart"
|
44
45
|
|
45
46
|
# For tests disable if not needed
|
46
47
|
default_config :chef_bootstrap_url, 'https://omnitruck.chef.io/install.sh'
|
@@ -74,7 +75,6 @@ module Kitchen
|
|
74
75
|
raise 'ansible extra_vars is in valid type: %s value: %s' % [config[:extra_vars].class.to_s, config[:extra_vars].to_s] unless extra_vars_is_valid
|
75
76
|
end
|
76
77
|
info('Ansible push config validated')
|
77
|
-
|
78
78
|
@validated_config = config
|
79
79
|
end
|
80
80
|
|
@@ -141,9 +141,18 @@ module Kitchen
|
|
141
141
|
def prepare_command
|
142
142
|
prepare_inventory if conf[:generate_inv]
|
143
143
|
# Place holder so a string is returned. This will execute true on remote host
|
144
|
-
|
144
|
+
true_command
|
145
145
|
end
|
146
146
|
|
147
|
+
def true_command
|
148
|
+
# Place holder so a string is returned. This will execute true on remote host
|
149
|
+
if conf[:ansible_connection] == "winrm"
|
150
|
+
'$TRUE'
|
151
|
+
else
|
152
|
+
'true'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
147
156
|
def install_command
|
148
157
|
# Must install chef for busser and serverspec to work :(
|
149
158
|
info('*************** AnsiblePush install_command ***************')
|
@@ -160,13 +169,16 @@ module Kitchen
|
|
160
169
|
end
|
161
170
|
|
162
171
|
def chef_installation(chef_url, omnibus_download_dir, transport)
|
163
|
-
|
172
|
+
|
173
|
+
if chef_url && (chef_url != 'nil') # ignore string nil
|
164
174
|
scripts = []
|
165
175
|
scripts << Util.shell_helpers
|
166
176
|
scripts << chef_installation_script(chef_url, omnibus_download_dir, transport)
|
167
177
|
<<-INSTALL
|
168
178
|
sh -c '#{scripts.join("\n")}'
|
169
179
|
INSTALL
|
180
|
+
else
|
181
|
+
true_command
|
170
182
|
end
|
171
183
|
end
|
172
184
|
|
@@ -205,7 +217,7 @@ module Kitchen
|
|
205
217
|
info('*************** AnsiblePush end run *******************')
|
206
218
|
debug("[#{name}] Converge completed (#{conf[:sleep]}s).")
|
207
219
|
# Place holder so a string is returned. This will execute true on remote host
|
208
|
-
|
220
|
+
true_command
|
209
221
|
end
|
210
222
|
|
211
223
|
protected
|
@@ -230,12 +242,16 @@ module Kitchen
|
|
230
242
|
def prepare_inventory
|
231
243
|
if instance_connection_option.nil?
|
232
244
|
hostname = machine_name
|
233
|
-
|
234
|
-
|
245
|
+
elsif not instance_connection_option()[:hostname].nil?
|
246
|
+
instance_connection_option()[:hostname]
|
247
|
+
elsif not instance_connection_option()[:endpoint].nil?
|
248
|
+
require 'uri'
|
249
|
+
urlhost = URI.parse(instance_connection_option()[:endpoint])
|
250
|
+
hostname = urlhost.host
|
235
251
|
end
|
236
252
|
debug("hostname='#{hostname}")
|
237
253
|
# Generate hosts
|
238
|
-
hosts = generate_instance_inventory(machine_name, hostname, conf[:mygroup], instance_connection_option)
|
254
|
+
hosts = generate_instance_inventory(machine_name, hostname, conf[:mygroup], instance_connection_option, conf[:ansible_connection])
|
239
255
|
write_var_to_yaml("#{TEMP_INV_DIR}/ansiblepush_host_#{machine_name}.yml", hosts)
|
240
256
|
# Generate groups (if defined)
|
241
257
|
write_var_to_yaml(TEMP_GROUP_FILE, conf[:groups]) if conf[:groups]
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
TEMP_INV_DIR = '.kitchen/ansiblepush'.freeze
|
3
2
|
TEMP_GROUP_FILE = "#{TEMP_INV_DIR}/ansiblepush_groups_inventory.yml".freeze
|
4
3
|
|
@@ -9,11 +8,12 @@ def write_var_to_yaml(yaml_file, hash_var)
|
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
12
|
-
def generate_instance_inventory(name, host, mygroup, instance_connection_option)
|
11
|
+
def generate_instance_inventory(name, host, mygroup, instance_connection_option, ansible_connection)
|
13
12
|
unless instance_connection_option.nil?
|
14
13
|
port = instance_connection_option[:port]
|
15
14
|
keys = instance_connection_option[:keys]
|
16
15
|
user = instance_connection_option[:user]
|
16
|
+
pass = instance_connection_option[:pass]
|
17
17
|
end
|
18
18
|
|
19
19
|
temp_hash = {}
|
@@ -21,6 +21,12 @@ def generate_instance_inventory(name, host, mygroup, instance_connection_option)
|
|
21
21
|
temp_hash['ansible_ssh_port'] = port if port
|
22
22
|
temp_hash['ansible_ssh_private_key_file'] = keys[0] if keys
|
23
23
|
temp_hash['ansible_ssh_user'] = user if user
|
24
|
+
temp_hash['ansible_ssh_pass'] = pass if pass
|
24
25
|
temp_hash['mygroup'] = mygroup if mygroup
|
26
|
+
# Windows issue ignore SSL
|
27
|
+
if ansible_connection == 'winrm'
|
28
|
+
temp_hash['ansible_winrm_server_cert_validation'] = 'ignore'
|
29
|
+
temp_hash['ansible_winrm_transport'] = 'ssl'
|
30
|
+
end
|
25
31
|
{ name => temp_hash }
|
26
32
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-ansiblepush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
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-
|
11
|
+
date: 2016-12-03 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
19
|
version: '0'
|
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
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: |+
|
@@ -69,13 +69,13 @@ extensions: []
|
|
69
69
|
extra_rdoc_files: []
|
70
70
|
files:
|
71
71
|
- README.md
|
72
|
+
- bin/kitchen-ansible-inventory
|
72
73
|
- callback/changes.py
|
73
74
|
- kitchen-ansiblepush.gemspec
|
74
75
|
- lib/kitchen-ansible/chef_installation.rb
|
75
76
|
- lib/kitchen-ansible/util_inventory.rb
|
76
77
|
- lib/kitchen-ansible/version.rb
|
77
78
|
- lib/kitchen/provisioner/ansible_push.rb
|
78
|
-
- bin/kitchen-ansible-inventory
|
79
79
|
homepage: https://github.com/ahelal/kitchen-ansiblepush
|
80
80
|
licenses:
|
81
81
|
- MIT
|
@@ -86,17 +86,17 @@ require_paths:
|
|
86
86
|
- lib
|
87
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
98
|
+
rubyforge_project: "[none]"
|
99
|
+
rubygems_version: 2.5.2
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: ansible provisioner for test-kitchen
|