kitchen-ansible 0.0.27 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c4491f1745701a0e990b9cacc7a48ce49556e36
4
- data.tar.gz: 5ecaaef24e5c27f0ac0de4d4a3b0ed3d50ef7bc9
3
+ metadata.gz: 223abb6eceecdfa8a197428c4039c950c0e99ad8
4
+ data.tar.gz: 987c669a9bff598a0cec647eb08d81fe99042282
5
5
  SHA512:
6
- metadata.gz: 3a6667c7da102e8e66a9dda3ea1e3a7969c4e2f6060baf26af177c590d39901fb121dd00ded1f34be3033953b71457310fa7e694805be245eb860adfbdaef274
7
- data.tar.gz: 9aa38376c4e48222cea3bd304771b301ae9e99414a141dedf8782ec6ed415b67c5a61e660c7a1c98fc8911ebe391b67deaac336e210abfa63a5f37be9aae3afd
6
+ metadata.gz: c5ce4e7d6dbcecbe5c5e144fcf8b0b53c79aacdddc0565b3817d6c6374651240046531b207dade245debef173fc7b21ae1395672d3af54010bfe40d8c188626e
7
+ data.tar.gz: 3ee1cb4eef68554143bd32d5078f613f8f87fefddf829103d595db6e2bf302b93ca1bf4c9e4b2ea67661df8902dfef62ef35ba6b01b00052d7cb60ebd8f57206
data/README.md CHANGED
@@ -48,25 +48,35 @@ platforms:
48
48
  network:
49
49
  - ['forwarded_port', {guest: 8080, host: 8080}]
50
50
  - [ 'private_network', { ip: '192.168.33.11' } ]
51
-
51
+
52
52
  verifier:
53
- ruby_bindir: '/usr/bin'
53
+ ruby_bindir: '/usr/bin'
54
54
  ```
55
55
  **NOTE:** With Test-Kitchen 1.4 you no longer need chef install to run the tests. You just need ruby installed version 1.9 or higher and also add to the `.kitchen.yml` file
56
56
 
57
57
  ```yaml
58
- verifier:
59
- ruby_bindir: '/usr/bin'
58
+ provisioner:
59
+ name: ansible_playbook
60
+ hosts: test-kitchen
61
+ require_chef_for_busser: false
62
+ require_ruby_for_busser: true
63
+
64
+ verifier:
65
+ ruby_bindir: '/usr/bin'
60
66
  ```
61
- where `/usr/bin` is the location of the ruby command.
67
+ where `/usr/bin` is the location of the ruby command.
68
+
62
69
 
70
+ ## Test-Kitchen Serverspec
63
71
 
64
- ## Test-Kitchen/Ansible/Serverspec
72
+ To run the verify step with the test-kitchen serverspec setup your ansible repository as follows:
73
+
74
+ NOTE: See https://github.com/delphix/ansible-package-caching-proxy for an example.
65
75
 
66
76
  In the root directory for your Ansible role:
67
77
 
68
78
  Create a `.kitchen.yml`, much like one the described above:
69
-
79
+
70
80
  ```yaml
71
81
  ---
72
82
  driver:
@@ -89,14 +99,14 @@ Create a `.kitchen.yml`, much like one the described above:
89
99
  box: chef/centos-7.0
90
100
 
91
101
  verifier:
92
- ruby_bindir: '/usr/bin'
102
+ ruby_bindir: '/usr/bin'
93
103
 
94
104
  suites:
95
105
  - name: default
96
106
  ```
97
107
 
98
108
  Then for serverspec:
99
-
109
+
100
110
  ```bash
101
111
  mkdir -p test/integration/default/serverspec/localhost
102
112
  echo "require 'serverspec'" >> test/integration/default/serverspec/spec_helper.rb
@@ -104,7 +114,7 @@ Then for serverspec:
104
114
  ```
105
115
 
106
116
  Create a basic playbook `test/integration/default.yml` so that kitchen can use your role (this should include any dependencies for your role):
107
-
117
+
108
118
  ```yaml
109
119
  ---
110
120
  - name: wrapper playbook for kitchen testing "my_role"
@@ -114,7 +124,7 @@ Create a basic playbook `test/integration/default.yml` so that kitchen can use y
114
124
  ```
115
125
 
116
126
  Create your serverspec tests in `test/integration/default/serverspec/localhost/my_roles_spec.rb`:
117
-
127
+
118
128
  ```ruby
119
129
  require 'spec_helper'
120
130
 
@@ -135,7 +145,64 @@ Create your serverspec tests in `test/integration/default/serverspec/localhost/m
135
145
  end
136
146
  ```
137
147
 
138
- ### Testing multiple playbooks
148
+ ## Test-Kitchen Ansiblespec
149
+
150
+ test-kitchen normally uses tests setup in `test/integration/....` directory. Ansiblespec format puts the tests with the
151
+ roles in the ansible repository and the spec helper is specified in the ansible repository under the spec directory.
152
+
153
+ To implement this with test-kitchen setup the ansible repository with:
154
+
155
+ * the spec files with the roles.
156
+
157
+ * the spec_helper in the spec folder.
158
+
159
+ * a dummy `test/integration/<suite>/ansiblespec/localhost/<suite>_spec.rb` containing just a dummy comment.
160
+
161
+ See example [https://github.com/neillturner/ansible_repo](https://github.com/neillturner/ansible_repo)
162
+
163
+ ```
164
+ .
165
+ +-- roles
166
+ ��� +-- mariadb
167
+ ��� ��� +-- spec
168
+ ��� ��� ��� +-- mariadb_spec.rb
169
+ ��� ��� +-- tasks
170
+ ��� ��� ��� +-- main.yml
171
+ ��� ��� +-- templates
172
+ ��� ��� +-- mariadb.repo
173
+ ��� +-- nginx
174
+ ��� +-- handlers
175
+ ��� ��� +-- main.yml
176
+ ��� +-- spec
177
+ ��� ��� +-- nginx_spec.rb
178
+ ��� +-- tasks
179
+ ��� ��� +-- main.yml
180
+ ��� +-- templates
181
+ ��� ��� +-- nginx.repo
182
+ ��� +-- vars
183
+ ��� +-- main.yml
184
+ +-- spec
185
+ +-- spec_helper.rb
186
+ +-- test
187
+ +-- integration
188
+ +-- default # name of test-kitchen suite
189
+ +-- ansiblespec
190
+ +-- localhost
191
+ +-- default_spec.rb # <suite>_spec.rb
192
+ ```
193
+
194
+ In the root directory for your Ansible role create a `.kitchen.yml`, the same as for test-kitchen serverspec above.
195
+
196
+ When test-kitchen runs the verify step will
197
+ * detect the dummy `/test/integration/<suite>/ansiblespec` directory
198
+ * install the busser-ansiblespec plugin instead of the normal busser-serverspec plugin
199
+ * serverspec will be called using the ansiblespec conventions.
200
+ * tests will run against all the roles in the playbook.
201
+
202
+ See [busser-ansiblespec](https://github.com/neillturner/busser-ansiblespec)
203
+
204
+
205
+ ## Testing multiple playbooks
139
206
  To test different playbooks in different suites you can easily overwrite the provisioner settings in each suite seperately.
140
207
  ```yaml
141
208
  ---
@@ -163,7 +230,7 @@ To test different playbooks in different suites you can easily overwrite the pro
163
230
  playbook: web_app.yml
164
231
  hosts: web_application
165
232
  ```
166
- ### Alternative Virtualization/Cloud providers for Vagrant
233
+ ## Alternative Virtualization/Cloud providers for Vagrant
167
234
  This could be adapted to use alternative virtualization/cloud providers such as Openstack/AWS/VMware Fusion according to whatever is supported by Vagrant.
168
235
  ```yaml
169
236
  platforms:
@@ -192,30 +259,20 @@ platforms:
192
259
  [packer]: https://packer.io
193
260
  [bento]: https://github.com/chef/bento
194
261
 
195
- ## Custom ServerSpec or AnsibleSpec Invocation
196
262
 
197
- Instead of using the busser use a custom serverspec invocation using [shell verifier](https://github.com/higanworks/kitchen-verifier-shell) to call it.
198
- With such setup there is no dependency on busser and any other chef library.
263
+ ## Tips
199
264
 
200
- Also you can specify you tests in a different directory structure or even call [ansible spec](https://github.com/volanja/ansible_spec) instead of server spec and have tests in ansible_spec structure
265
+ You can easily skip previous instructions and jump directly to the broken statement you just fixed by passing
266
+ an environment variable. Add folloing to your .kitchen.yml
201
267
 
202
- Using a structure like
203
268
  ```yaml
204
- verifier:
205
- name: shell
206
- remote_exec: true
207
- command: |
208
- sudo -s <<SERVERSPEC
209
- cd /opt/gdc/serverspec-core
210
- export SERVERSPEC_ENV=$EC2DATA_ENVIRONMENT
211
- export SERVERSPEC_BACKEND=exec
212
- serverspec junit=true tag=~skip_in_kitchen check:role:$EC2DATA_TYPE
213
- SERVERSPEC
269
+ provisioner:
270
+ name: ansible_playbook
271
+ ansible_extra_flags: <%= ENV['ANSIBLE_EXTRA_FLAGS'] %>
214
272
  ```
215
273
 
216
- where `serverspec` is a wrapper around `rake` invocation.
217
- Use a `Rakefile` similar to one in https://github.com/vincentbernat/serverspec-example.
274
+ run:
218
275
 
219
- With such approach we can achieve flexibility of running same test suite both in test kitchen and actual, even production, instances.
276
+ `ANSIBLE_EXTRA_FLAGS='--start-at-task="myrole | name of last working instruction"' kitchen converge`
220
277
 
221
- Beware: kitchen-shell-verifier is not yet merged into test-kitchen upstream so using separate gem is unavoidable so far
278
+ You save a LOT of time not running working instructions.
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Ansible
3
- VERSION = "0.0.27"
3
+ VERSION = "0.0.28"
4
4
  end
5
5
  end
@@ -223,6 +223,7 @@ module Kitchen
223
223
  prepare_additional_copy_path
224
224
  prepare_host_vars
225
225
  prepare_hosts
226
+ prepare_spec
226
227
  prepare_filter_plugins
227
228
  prepare_lookup_plugins
228
229
  prepare_ansible_vault_password_file
@@ -279,6 +280,9 @@ module Kitchen
279
280
  else
280
281
  cmd = ansible_command("ansible-playbook")
281
282
  end
283
+ if config[:ansible_binary_path]
284
+ cmd = ansible_command("#{config[:ansible_binary_path]}/ansible-playbook")
285
+ end
282
286
  if https_proxy
283
287
  cmd = "HTTPS_PROXY=#{https_proxy} #{cmd}"
284
288
  end
@@ -337,7 +341,7 @@ module Kitchen
337
341
  #{export_http_proxy}
338
342
  git clone git://github.com/ansible/ansible.git --recursive #{config[:root_path]}/ansible
339
343
  #{sudo_env('easy_install')} pip
340
- #{sudo_env('pip')} install paramiko PyYAML Jinja2 httplib2
344
+ #{sudo_env('pip')} install six paramiko PyYAML Jinja2 httplib2
341
345
  fi
342
346
  INSTALL
343
347
  end
@@ -446,6 +450,10 @@ module Kitchen
446
450
  File.join(sandbox_path, 'roles')
447
451
  end
448
452
 
453
+ def tmp_spec_dir
454
+ File.join(sandbox_path, 'spec')
455
+ end
456
+
449
457
  def tmp_filter_plugins_dir
450
458
  File.join(sandbox_path, 'filter_plugins')
451
459
  end
@@ -490,6 +498,10 @@ module Kitchen
490
498
  config[:modules_path]
491
499
  end
492
500
 
501
+ def spec
502
+ 'spec'
503
+ end
504
+
493
505
  def group_vars
494
506
  config[:group_vars_path].to_s
495
507
  end
@@ -789,6 +801,19 @@ module Kitchen
789
801
  end
790
802
  end
791
803
 
804
+ def prepare_spec
805
+ info('Preparing spec')
806
+
807
+ FileUtils.mkdir_p(tmp_spec_dir)
808
+
809
+ if spec && File.directory?(spec)
810
+ debug("Using spec from #{spec}")
811
+ FileUtils.cp_r(Dir.glob("#{spec}/*"), tmp_spec_dir, remove_destination: true)
812
+ else
813
+ info 'nothing to do for spec'
814
+ end
815
+ end
816
+
792
817
  def prepare_filter_plugins
793
818
  info('Preparing filter_plugins')
794
819
  FileUtils.mkdir_p(tmp_filter_plugins_dir)
@@ -9,6 +9,7 @@ ansible_platform | naively tries to determine | OS platform of server
9
9
  require_ansible_repo | true | Set if using a ansible install from yum or apt repo
10
10
  ansible_apt_repo | "ppa:ansible/ansible" | apt repo. see https://launchpad.net /~ansible/+archive/ubuntu/ansible or rquillo/ansible
11
11
  ansible_yum_repo | https://download.fedoraproject.org /pub/epel/6/i386/epel-release-6-8.noarch.rpm | yum repo RH/Centos6
12
+ ansible_binary_path | NULL | If specified this will override the location where kitchen tries to run ansible-playbook from. ie: (ansible_binary_path: /usr/local/bin )
12
13
  _for RH/Centos7 change to_ | http://dl.fedoraproject.org /pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm |
13
14
  enable_yum_epel | false | enable yum EPEL repo
14
15
  ansible_sles_repo | http://download.opensuse.org/repositories /systemsmanagement/SLE_12/systemsmanagement.repo | zypper suse ansible repo
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.0.27
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neill Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-27 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen