kitchen-ansible 0.45.4 → 0.45.5

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: e8c5380fe9e1ad20a849fa4160b1d74ca479d79e
4
- data.tar.gz: 52240f3ae11fc57b9d6a2b3d44825a077c26fff3
3
+ metadata.gz: 838f04b6321b4fd0f2f4ac3db1c4ee31ad62ead3
4
+ data.tar.gz: 239581647b00fbc9a117f55b4e7bf43efc65e286
5
5
  SHA512:
6
- metadata.gz: 0a316c4eb405e6e85d41b517a4f4e3f4a7a0581e43de45fd908ad9d1df85f668aaf0b3c724cb4b43b9c3fcb1151317659a539e2676b96ce8d0c8865b9567acc2
7
- data.tar.gz: c468db5a389d23d56da76ee84d7791b656293958622b234b64c782f38a0a15f13fb42aae435625df3ad62f8a26f5ceb1b5b15fd59d5e2965b840224deefee22a
6
+ metadata.gz: 065f7eb5d596915ef94dc5aebf993e01254c15617e65e07cfb47bf49596358031fd9475dba25d0bc1eb26f195467fabc94c4c498dd4fdf2939278208200558e8
7
+ data.tar.gz: 7298102bffd0bd132d4ba291db49a2eada0741d303bb4657446e7553a3c5289758e663305ae1e9f35d2535a8034cdc852022cfa1e16c46ea1d37d92d3136ef95
data/README.md CHANGED
@@ -1,232 +1,232 @@
1
- # kitchen-ansible
2
-
3
- [![Gem Version](https://badge.fury.io/rb/kitchen-ansible.svg)](http://badge.fury.io/rb/kitchen-ansible)
4
- [![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/kitchen-ansible?type=total&color=brightgreen)](https://rubygems.org/gems/kitchen-ansible)
5
- [![Build Status](https://travis-ci.org/neillturner/kitchen-ansible.png)](https://travis-ci.org/neillturner/kitchen-ansible)
6
-
7
- A Test Kitchen Provisioner for Ansible.
8
-
9
- The provisioner works by passing the Ansible repository based on attributes in `.kitchen.yml` & calling `ansible-playbook`.
10
-
11
- It installs Ansible on the server and runs `ansible-playbook` using host localhost.
12
-
13
- It has been tested against the Ubuntu 12.04, Ubuntu 14.04, Centos 6.5 and Debian 6/7/8 boxes running in vagrant/virtualbox.
14
-
15
- ## Requirements
16
- - [Test Kitchen](https://github.com/test-kitchen/test-kitchen).
17
- - a driver box without a Chef installation so Ansible can be installed.
18
-
19
- ## Installation & Setup
20
- Install the `kitchen-ansible` gem in your system, along with [kitchen-vagrant](https://github.com/test-kitchen/kitchen-vagrant) or [kitchen-docker](https://github.com/test-kitchen/kitchen-docker) or any other suitable driver:
21
-
22
- ```
23
- gem install kitchen-ansible
24
- gem install kitchen-vagrant
25
- ```
26
-
27
- ## Example .kitchen.yml file
28
-
29
- Based on the [Tomcat Standalone](https://github.com/ansible/ansible-examples/tree/master/tomcat-standalone) example:
30
-
31
- ```yaml
32
- ---
33
- driver:
34
- name: vagrant
35
-
36
- provisioner:
37
- name: ansible_playbook
38
- roles_path: roles
39
- hosts: tomcat-servers
40
- require_ansible_repo: true
41
- ansible_verbose: true
42
- ansible_version: latest
43
-
44
- platforms:
45
- - name: nocm_centos-6.5
46
- driver_plugin: vagrant
47
- driver_config:
48
- box: nocm_centos-6.5
49
- box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
50
- network:
51
- - ['forwarded_port', {guest: 8080, host: 8080}]
52
- - ['private_network', {ip: '192.168.33.11'}]
53
- ```
54
-
55
- ## Windows Support
56
-
57
- Windows is supported by creating a linux server to run Ansible with software required to support winrm. Then the winrm connection is used to configure the windows server.
58
-
59
- In `.kitchen.yml` set:
60
-
61
- ```yaml
62
- ansible_connection: winrm
63
- require_windows_support: true
64
- require_chef_for_busser: false
65
- ```
66
-
67
- See the [Ansible Windows repo](https://github.com/neillturner/ansible_windows_repo) example.
68
-
69
- ## Using Roles from Ansible Galaxy
70
-
71
- Roles can be used from the Ansible Galaxy using two methods:
72
-
73
- 1. Specify a `requirements.yml` file in your Ansible repository. For more details see [here](http://docs.ansible.com/ansible/galaxy.html).
74
-
75
- 2. Use `librarian-ansible` by creating an `Ansiblefile` in the top level of the repository and `kitchen-ansible` will automatically call `librarian-ansible` during convergence. For a description of setting up an `Ansiblefile` see [here](https://werner-dijkerman.nl/2015/08/15/using-librarian-ansible-to-install-ansible-roles-from-gitlab/).
76
-
77
- ## Tips
78
-
79
- To use a single ~/.kitchen/config.yml file with multiple reposities by setting the WORKSPACE environment variable:
80
-
81
- ```yaml
82
- role_path: <%= ENV['WORKSPACE'] %>/roles
83
- ```
84
-
85
- You can easily skip previous instructions and jump directly to the broken statement you just fixed by passing an environment variable. Add the following to your `.kitchen.yml`:
86
-
87
- ```yaml
88
- provisioner:
89
- name: ansible_playbook
90
- ansible_extra_flags: <%= ENV['ANSIBLE_EXTRA_FLAGS'] %>
91
- ```
92
-
93
- Then run:
94
-
95
- ```
96
- $ ANSIBLE_EXTRA_FLAGS='--start-at-task="myrole | name of last working instruction"' kitchen converge
97
- ```
98
-
99
- You save a lot of time not running working instructions.
100
-
101
-
102
- ## Ruby install to run Serverspec verify
103
-
104
- By default test-kitchen installs Chef to get a Ruby version suitable to run Serverspec in the `verify` step.
105
- Instead Ruby can just be installed by specifying the provisioner option:
106
-
107
- ```yaml
108
- require_ruby_for_busser: true
109
- ```
110
- And set the verifier section:
111
- ```yaml
112
- verifier:
113
- name: serverspec
114
- sudo_path: true
115
-
116
- suites:
117
- - name: ansible
118
- driver_config:
119
- hostname: '54.229.34.169'
120
- verifier:
121
- patterns:
122
- - roles/tomcat/spec/tomcat_spec.rb
123
- bundler_path: '/usr/local/bin'
124
- rspec_path: '/usr/local/bin'
125
- env_vars:
126
- TARGET_HOST: 54.229.104.40
127
- LOGIN_USER: centos
128
- SUDO: true
129
- SSH_KEY: spec/test.pem
130
- ```
131
-
132
- Please see the [Provisioner Options](https://github.com/neillturner/kitchen-ansible/blob/master/provisioner_options.md) for a complete listing.
133
-
134
- ## Test-Kitchen Ansiblespec
135
-
136
- By using kitchen-verifier-serverspec and the Runner ansiblespec_runner tests can be run against multiple servers with multiple roles in the ansiblespec format.
137
-
138
- Serverspec uses ssh to communicate with the server to be tested and reads the Ansible playbook and inventory files to determine the hosts to test and the roles for each host.
139
-
140
- See example [https://github.com/neillturner/ansible_repo](https://github.com/neillturner/ansible_repo)
141
-
142
- ### Example usage to create Tomcat servers:
143
-
144
- ![test-kitchen, Ansible and ansiblespec](https://github.com/neillturner/ansible_repo/blob/master/kitchen-ansible.png "test-kitchen, ansible and ansiblespec")
145
-
146
- See [ansible-sample-tdd](https://github.com/volanja/ansible-sample-tdd).
147
-
148
- ### Usage
149
-
150
- #### Directory
151
-
152
- In the Ansible repository specify:
153
-
154
- * spec files with the roles.
155
- * spec_helper in the spec folder (with code as below).
156
-
157
- ```
158
- .
159
- +-- roles
160
- ¦   +-- mariadb
161
- ¦   ¦   +-- spec
162
- ¦   ¦   ¦   +-- mariadb_spec.rb
163
- ¦   ¦   +-- tasks
164
- ¦   ¦   ¦   +-- main.yml
165
- ¦   ¦   +-- templates
166
- ¦   ¦   +-- mariadb.repo
167
- ¦   +-- nginx
168
- ¦   +-- handlers
169
- ¦   ¦   +-- main.yml
170
- ¦   +-- spec
171
- ¦   ¦   +-- nginx_spec.rb
172
- ¦   +-- tasks
173
- ¦   ¦   +-- main.yml
174
- ¦   +-- templates
175
- ¦   ¦   +-- nginx.repo
176
- ¦   +-- vars
177
- ¦   +-- main.yml
178
- +-- spec
179
- +-- spec_helper.rb
180
- +-- my_private_key.pem
181
- ```
182
-
183
-
184
- #### spec_helper
185
-
186
- ```ruby
187
- require 'rubygems'
188
- require 'bundler/setup'
189
-
190
- require 'serverspec'
191
- require 'pathname'
192
- require 'net/ssh'
193
-
194
- RSpec.configure do |config|
195
- set :host, ENV['TARGET_HOST']
196
- # ssh options at http://net-ssh.github.io/ssh/v1/chapter-2.html
197
- # ssh via password
198
- set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :password => ENV['LOGIN_PASSWORD'] if ENV['LOGIN_PASSWORD']
199
- # ssh via ssh key
200
- set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :host_key => 'ssh-rsa', :keys => [ ENV['SSH_KEY'] ] if ENV['SSH_KEY']
201
- set :backend, :ssh
202
- set :request_pty, true
203
- end
204
- ```
205
-
206
- See [kitchen-verifier-serverspec](https://github.com/neillturner/kitchen-verifier-serverspec).
207
-
208
- ## Alternative Virtualization/Cloud providers for Vagrant
209
- This could be adapted to use alternative virtualization/cloud providers such as Openstack/AWS/VMware Fusion according to whatever is supported by Vagrant.
210
- ```yaml
211
- platforms:
212
- - name: ubuntu-12.04
213
- driver_config:
214
- provider: aws
215
- box: my_base_box
216
- # username is based on what is configured in your box/ami
217
- username: ubuntu
218
- customize:
219
- access_key_id: 'AKKJHG659868LHGLH'
220
- secret_access_key: 'G8t7o+6HLG876JGF/58'
221
- ami: ami-7865ab765d
222
- instance_type: t2.micro
223
- # more customisation can go here, based on what the vagrant provider supports
224
- #security-groups: []
225
- ```
226
-
227
- ## Notes
228
-
229
- * The `default` in all of the above is the name of the test suite defined in the `suites` section of your `.kitchen.yml`, so if you have more than one suite of tests or change the name, you'll need to adapt the example accordingly.
230
- * Serverspec test files *must* be named `_spec.rb`
231
- * Since I'm using Vagrant, my `box` definitions refer to Vagrant boxes, either standard, published boxes available from [Atlas](http://atlas.hashicorp.com/boxes) or custom-created boxes (perhaps using [Packer](http://packer.io) and [bento](https://github.com/chef/bento), in which case you'll need to provide the URL in `box_url`.
232
-
1
+ # kitchen-ansible
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/kitchen-ansible.svg)](http://badge.fury.io/rb/kitchen-ansible)
4
+ [![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/kitchen-ansible?type=total&color=brightgreen)](https://rubygems.org/gems/kitchen-ansible)
5
+ [![Build Status](https://travis-ci.org/neillturner/kitchen-ansible.png)](https://travis-ci.org/neillturner/kitchen-ansible)
6
+
7
+ A Test Kitchen Provisioner for Ansible.
8
+
9
+ The provisioner works by passing the Ansible repository based on attributes in `.kitchen.yml` & calling `ansible-playbook`.
10
+
11
+ It installs Ansible on the server and runs `ansible-playbook` using host localhost.
12
+
13
+ It has been tested against the Ubuntu 12.04/14.04/16.04, Centos 6/7 and Debian 6/7/8 boxes running in vagrant/virtualbox.
14
+
15
+ ## Requirements
16
+ - [Test Kitchen](https://github.com/test-kitchen/test-kitchen).
17
+ - a driver box without a Chef installation so Ansible can be installed.
18
+
19
+ ## Installation & Setup
20
+ Install the `kitchen-ansible` gem in your system, along with [kitchen-vagrant](https://github.com/test-kitchen/kitchen-vagrant) or [kitchen-docker](https://github.com/test-kitchen/kitchen-docker) or any other suitable driver:
21
+
22
+ ```
23
+ gem install kitchen-ansible
24
+ gem install kitchen-vagrant
25
+ ```
26
+
27
+ ## Example .kitchen.yml file
28
+
29
+ Based on the [Tomcat Standalone](https://github.com/ansible/ansible-examples/tree/master/tomcat-standalone) example:
30
+
31
+ ```yaml
32
+ ---
33
+ driver:
34
+ name: vagrant
35
+
36
+ provisioner:
37
+ name: ansible_playbook
38
+ roles_path: roles
39
+ hosts: tomcat-servers
40
+ require_ansible_repo: true
41
+ ansible_verbose: true
42
+ ansible_version: latest
43
+
44
+ platforms:
45
+ - name: nocm_centos-6.5
46
+ driver_plugin: vagrant
47
+ driver_config:
48
+ box: nocm_centos-6.5
49
+ box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
50
+ network:
51
+ - ['forwarded_port', {guest: 8080, host: 8080}]
52
+ - ['private_network', {ip: '192.168.33.11'}]
53
+ ```
54
+
55
+ ## Windows Support
56
+
57
+ Windows is supported by creating a linux server to run Ansible with software required to support winrm. Then the winrm connection is used to configure the windows server.
58
+
59
+ In `.kitchen.yml` set:
60
+
61
+ ```yaml
62
+ ansible_connection: winrm
63
+ require_windows_support: true
64
+ require_chef_for_busser: false
65
+ ```
66
+
67
+ See the [Ansible Windows repo](https://github.com/neillturner/ansible_windows_repo) example.
68
+
69
+ ## Using Roles from Ansible Galaxy
70
+
71
+ Roles can be used from the Ansible Galaxy using two methods:
72
+
73
+ 1. Specify a `requirements.yml` file in your Ansible repository. For more details see [here](http://docs.ansible.com/ansible/galaxy.html).
74
+
75
+ 2. Use `librarian-ansible` by creating an `Ansiblefile` in the top level of the repository and `kitchen-ansible` will automatically call `librarian-ansible` during convergence. For a description of setting up an `Ansiblefile` see [here](https://werner-dijkerman.nl/2015/08/15/using-librarian-ansible-to-install-ansible-roles-from-gitlab/).
76
+
77
+ ## Tips
78
+
79
+ To use a single ~/.kitchen/config.yml file with multiple reposities by setting the WORKSPACE environment variable:
80
+
81
+ ```yaml
82
+ role_path: <%= ENV['WORKSPACE'] %>/roles
83
+ ```
84
+
85
+ You can easily skip previous instructions and jump directly to the broken statement you just fixed by passing an environment variable. Add the following to your `.kitchen.yml`:
86
+
87
+ ```yaml
88
+ provisioner:
89
+ name: ansible_playbook
90
+ ansible_extra_flags: <%= ENV['ANSIBLE_EXTRA_FLAGS'] %>
91
+ ```
92
+
93
+ Then run:
94
+
95
+ ```
96
+ $ ANSIBLE_EXTRA_FLAGS='--start-at-task="myrole | name of last working instruction"' kitchen converge
97
+ ```
98
+
99
+ You save a lot of time not running working instructions.
100
+
101
+
102
+ ## Ruby install to run Serverspec verify
103
+
104
+ By default test-kitchen installs Chef to get a Ruby version suitable to run Serverspec in the `verify` step.
105
+ Instead Ruby can just be installed by specifying the provisioner option:
106
+
107
+ ```yaml
108
+ require_ruby_for_busser: true
109
+ ```
110
+ And set the verifier section:
111
+ ```yaml
112
+ verifier:
113
+ name: serverspec
114
+ sudo_path: true
115
+
116
+ suites:
117
+ - name: ansible
118
+ driver_config:
119
+ hostname: '54.229.34.169'
120
+ verifier:
121
+ patterns:
122
+ - roles/tomcat/spec/tomcat_spec.rb
123
+ bundler_path: '/usr/local/bin'
124
+ rspec_path: '/usr/local/bin'
125
+ env_vars:
126
+ TARGET_HOST: 54.229.104.40
127
+ LOGIN_USER: centos
128
+ SUDO: true
129
+ SSH_KEY: spec/test.pem
130
+ ```
131
+
132
+ Please see the [Provisioner Options](https://github.com/neillturner/kitchen-ansible/blob/master/provisioner_options.md) for a complete listing.
133
+
134
+ ## Test-Kitchen Ansiblespec
135
+
136
+ By using kitchen-verifier-serverspec and the Runner ansiblespec_runner tests can be run against multiple servers with multiple roles in the ansiblespec format.
137
+
138
+ Serverspec uses ssh to communicate with the server to be tested and reads the Ansible playbook and inventory files to determine the hosts to test and the roles for each host.
139
+
140
+ See example [https://github.com/neillturner/ansible_repo](https://github.com/neillturner/ansible_repo)
141
+
142
+ ### Example usage to create Tomcat servers:
143
+
144
+ ![test-kitchen, Ansible and ansiblespec](https://github.com/neillturner/ansible_repo/blob/master/kitchen-ansible.png "test-kitchen, ansible and ansiblespec")
145
+
146
+ See [ansible-sample-tdd](https://github.com/volanja/ansible-sample-tdd).
147
+
148
+ ### Usage
149
+
150
+ #### Directory
151
+
152
+ In the Ansible repository specify:
153
+
154
+ * spec files with the roles.
155
+ * spec_helper in the spec folder (with code as below).
156
+
157
+ ```
158
+ .
159
+ +-- roles
160
+ ¦   +-- mariadb
161
+ ¦   ¦   +-- spec
162
+ ¦   ¦   ¦   +-- mariadb_spec.rb
163
+ ¦   ¦   +-- tasks
164
+ ¦   ¦   ¦   +-- main.yml
165
+ ¦   ¦   +-- templates
166
+ ¦   ¦   +-- mariadb.repo
167
+ ¦   +-- nginx
168
+ ¦   +-- handlers
169
+ ¦   ¦   +-- main.yml
170
+ ¦   +-- spec
171
+ ¦   ¦   +-- nginx_spec.rb
172
+ ¦   +-- tasks
173
+ ¦   ¦   +-- main.yml
174
+ ¦   +-- templates
175
+ ¦   ¦   +-- nginx.repo
176
+ ¦   +-- vars
177
+ ¦   +-- main.yml
178
+ +-- spec
179
+ +-- spec_helper.rb
180
+ +-- my_private_key.pem
181
+ ```
182
+
183
+
184
+ #### spec_helper
185
+
186
+ ```ruby
187
+ require 'rubygems'
188
+ require 'bundler/setup'
189
+
190
+ require 'serverspec'
191
+ require 'pathname'
192
+ require 'net/ssh'
193
+
194
+ RSpec.configure do |config|
195
+ set :host, ENV['TARGET_HOST']
196
+ # ssh options at http://net-ssh.github.io/ssh/v1/chapter-2.html
197
+ # ssh via password
198
+ set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :password => ENV['LOGIN_PASSWORD'] if ENV['LOGIN_PASSWORD']
199
+ # ssh via ssh key
200
+ set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :host_key => 'ssh-rsa', :keys => [ ENV['SSH_KEY'] ] if ENV['SSH_KEY']
201
+ set :backend, :ssh
202
+ set :request_pty, true
203
+ end
204
+ ```
205
+
206
+ See [kitchen-verifier-serverspec](https://github.com/neillturner/kitchen-verifier-serverspec).
207
+
208
+ ## Alternative Virtualization/Cloud providers for Vagrant
209
+ This could be adapted to use alternative virtualization/cloud providers such as Openstack/AWS/VMware Fusion according to whatever is supported by Vagrant.
210
+ ```yaml
211
+ platforms:
212
+ - name: ubuntu-12.04
213
+ driver_config:
214
+ provider: aws
215
+ box: my_base_box
216
+ # username is based on what is configured in your box/ami
217
+ username: ubuntu
218
+ customize:
219
+ access_key_id: 'AKKJHG659868LHGLH'
220
+ secret_access_key: 'G8t7o+6HLG876JGF/58'
221
+ ami: ami-7865ab765d
222
+ instance_type: t2.micro
223
+ # more customisation can go here, based on what the vagrant provider supports
224
+ #security-groups: []
225
+ ```
226
+
227
+ ## Notes
228
+
229
+ * The `default` in all of the above is the name of the test suite defined in the `suites` section of your `.kitchen.yml`, so if you have more than one suite of tests or change the name, you'll need to adapt the example accordingly.
230
+ * Serverspec test files *must* be named `_spec.rb`
231
+ * Since I'm using Vagrant, my `box` definitions refer to Vagrant boxes, either standard, published boxes available from [Atlas](http://atlas.hashicorp.com/boxes) or custom-created boxes (perhaps using [Packer](http://packer.io) and [bento](https://github.com/chef/bento), in which case you'll need to provide the URL in `box_url`.
232
+