kitchen-ansible 0.0.17 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +195 -172
- data/kitchen-ansible.gemspec +35 -35
- data/lib/kitchen-ansible/version.rb +5 -5
- data/lib/kitchen/provisioner/ansible/config.rb +144 -139
- data/lib/kitchen/provisioner/ansible/librarian.rb +83 -83
- data/lib/kitchen/provisioner/ansible_playbook.rb +673 -632
- data/provisioner_options.md +93 -92
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3518b7a91eb4d4bcdbf4d17e130a2996749c0db
|
4
|
+
data.tar.gz: 28b8664e3f61106ffd755cd0daf103e2d5ee6454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49e12a7fe4c7380ff40c8b4fe693e081d9bd2663a25f07c2ce79adfd0e56875c78adf12e7ace774fae0eaa9070278c3bcba80f8ebfa71e9538fa3179e4c5c630
|
7
|
+
data.tar.gz: a29a978db1784b9d3f98de4e7d86a99b823736a809fc591c021f7fb7dda238487a45151f513ccc3b93ac9b64ee5c641b55bf6200012eecbbeefc4a2bb9c92c9b
|
data/README.md
CHANGED
@@ -1,172 +1,195 @@
|
|
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
|
10
|
-
|
11
|
-
It
|
12
|
-
|
13
|
-
Has been tested against the Ubuntu 1204 and Centos 6.5 boxes running in vagrant/virtualbox.
|
14
|
-
|
15
|
-
## Requirements
|
16
|
-
You'll need a driver box without a chef installation so ansible can be installed.
|
17
|
-
|
18
|
-
## Installation & Setup
|
19
|
-
You'll need the test-kitchen & kitchen-ansible gem's installed in your system, along with kitchen-vagrant or some other suitable driver for test-kitchen.
|
20
|
-
|
21
|
-
Please see the Provisioner Options (https://github.com/neillturner/kitchen-ansible/blob/master/provisioner_options.md).
|
22
|
-
|
23
|
-
## Example kitchen.yml file
|
24
|
-
|
25
|
-
based on the example ansible setup for tomcat at https://github.com/ansible/ansible-examples/tree/master/tomcat-standalone
|
26
|
-
|
27
|
-
```yaml
|
28
|
-
---
|
29
|
-
driver:
|
30
|
-
name: vagrant
|
31
|
-
|
32
|
-
provisioner:
|
33
|
-
name: ansible_playbook
|
34
|
-
roles_path: roles
|
35
|
-
hosts: tomcat-servers
|
36
|
-
require_ansible_repo: true
|
37
|
-
ansible_verbose: true
|
38
|
-
ansible_version: 1.6.2-1.el6
|
39
|
-
extra_vars:
|
40
|
-
a: b
|
41
|
-
|
42
|
-
platforms:
|
43
|
-
- name: nocm_centos-6.5
|
44
|
-
driver_plugin: vagrant
|
45
|
-
driver_config:
|
46
|
-
box: nocm_centos-6.5
|
47
|
-
box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
|
48
|
-
network:
|
49
|
-
- ['forwarded_port', {guest: 8080, host: 8080}]
|
50
|
-
- [ 'private_network', { ip: '192.168.33.11' } ]
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
- name:
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
+
Has been tested against the Ubuntu 1204 and Centos 6.5 boxes running in vagrant/virtualbox.
|
14
|
+
|
15
|
+
## Requirements
|
16
|
+
You'll need a driver box without a chef installation so ansible can be installed.
|
17
|
+
|
18
|
+
## Installation & Setup
|
19
|
+
You'll need the test-kitchen & kitchen-ansible gem's installed in your system, along with kitchen-vagrant or some other suitable driver for test-kitchen.
|
20
|
+
|
21
|
+
Please see the Provisioner Options (https://github.com/neillturner/kitchen-ansible/blob/master/provisioner_options.md).
|
22
|
+
|
23
|
+
## Example kitchen.yml file
|
24
|
+
|
25
|
+
based on the example ansible setup for tomcat at https://github.com/ansible/ansible-examples/tree/master/tomcat-standalone
|
26
|
+
|
27
|
+
```yaml
|
28
|
+
---
|
29
|
+
driver:
|
30
|
+
name: vagrant
|
31
|
+
|
32
|
+
provisioner:
|
33
|
+
name: ansible_playbook
|
34
|
+
roles_path: roles
|
35
|
+
hosts: tomcat-servers
|
36
|
+
require_ansible_repo: true
|
37
|
+
ansible_verbose: true
|
38
|
+
ansible_version: 1.6.2-1.el6
|
39
|
+
extra_vars:
|
40
|
+
a: b
|
41
|
+
|
42
|
+
platforms:
|
43
|
+
- name: nocm_centos-6.5
|
44
|
+
driver_plugin: vagrant
|
45
|
+
driver_config:
|
46
|
+
box: nocm_centos-6.5
|
47
|
+
box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
|
48
|
+
network:
|
49
|
+
- ['forwarded_port', {guest: 8080, host: 8080}]
|
50
|
+
- [ 'private_network', { ip: '192.168.33.11' } ]
|
51
|
+
|
52
|
+
verifier:
|
53
|
+
ruby_bindir: '/usr/bin'
|
54
|
+
```
|
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
|
+
|
57
|
+
```yaml
|
58
|
+
verifier:
|
59
|
+
ruby_bindir: '/usr/bin'
|
60
|
+
```
|
61
|
+
where /usr/bin is the location of the ruby command.
|
62
|
+
|
63
|
+
|
64
|
+
## Test-Kitchen/Ansible/Serverspec
|
65
|
+
|
66
|
+
In the root directory for your Ansible role:
|
67
|
+
|
68
|
+
Create a `.kitchen.yml`, much like one the described above:
|
69
|
+
|
70
|
+
```yaml
|
71
|
+
---
|
72
|
+
driver:
|
73
|
+
name: vagrant
|
74
|
+
|
75
|
+
provisioner:
|
76
|
+
name: ansible_playbook
|
77
|
+
playbook: default.yml
|
78
|
+
ansible_yum_repo: "https://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm"
|
79
|
+
ansible_verbose: true
|
80
|
+
ansible_verbosity: 3
|
81
|
+
hosts: all
|
82
|
+
|
83
|
+
platforms:
|
84
|
+
- name: ubuntu-12.04
|
85
|
+
driver_config:
|
86
|
+
box: ubuntu/precise32
|
87
|
+
- name: centos-7
|
88
|
+
driver_config:
|
89
|
+
box: chef/centos-7.0
|
90
|
+
|
91
|
+
verifier:
|
92
|
+
ruby_bindir: '/usr/bin'
|
93
|
+
|
94
|
+
suites:
|
95
|
+
- name: default
|
96
|
+
```
|
97
|
+
|
98
|
+
Then for serverspec:
|
99
|
+
|
100
|
+
```bash
|
101
|
+
mkdir -p test/integration/default/serverspec/localhost
|
102
|
+
echo "require 'serverspec'" >> test/integration/default/serverspec/spec_helper.rb
|
103
|
+
echo "set :backend, :exec" >> test/integration/default/serverspec/spec_helper.rb
|
104
|
+
```
|
105
|
+
|
106
|
+
Create a basic playbook `test/integration/default.yml` so that kitchen can use your role (this should include any dependencies for your role):
|
107
|
+
|
108
|
+
```yaml
|
109
|
+
---
|
110
|
+
- name: wrapper playbook for kitchen testing "my_role"
|
111
|
+
hosts: localhost
|
112
|
+
roles:
|
113
|
+
- my_role
|
114
|
+
```
|
115
|
+
|
116
|
+
Create your serverspec tests in `test/integration/default/serverspec/localhost/my_roles_spec.rb`:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
require 'spec_helper'
|
120
|
+
|
121
|
+
if os[:family] == 'ubuntu'
|
122
|
+
describe '/etc/lsb-release' do
|
123
|
+
it "exists" do
|
124
|
+
expect(file('/etc/lsb-release')).to be_file
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if os[:family] == 'redhat'
|
130
|
+
describe '/etc/redhat-release' do
|
131
|
+
it "exists" do
|
132
|
+
expect(file('/etc/redhat-release')).to be_file
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
```
|
137
|
+
|
138
|
+
### Testing multiple playbooks
|
139
|
+
To test different playbooks in different suites you can easily overwrite the provisioner settings in each suite seperately.
|
140
|
+
```yaml
|
141
|
+
---
|
142
|
+
driver:
|
143
|
+
name: vagrant
|
144
|
+
|
145
|
+
provisioner:
|
146
|
+
name: ansible_playbook
|
147
|
+
|
148
|
+
platforms:
|
149
|
+
- name: ubuntu-12.04
|
150
|
+
driver_config:
|
151
|
+
box: ubuntu/precise32
|
152
|
+
- name: centos-7
|
153
|
+
driver_config:
|
154
|
+
box: chef/centos-7.0
|
155
|
+
|
156
|
+
suites:
|
157
|
+
- name: database
|
158
|
+
provisioner:
|
159
|
+
playbook: postgres.yml
|
160
|
+
hosts: database
|
161
|
+
- name: application
|
162
|
+
provisioner:
|
163
|
+
playbook: web_app.yml
|
164
|
+
hosts: web_application
|
165
|
+
```
|
166
|
+
|
167
|
+
### Alternative Virtualization/Cloud providers for Vagrant
|
168
|
+
This could be adapted to use alternative virtualization/cloud providers such as Openstack/AWS/VMware Fusion according to whatever is supported by Vagrant.
|
169
|
+
```yaml
|
170
|
+
platforms:
|
171
|
+
- name: ubuntu-12.04
|
172
|
+
driver_config:
|
173
|
+
provider: aws
|
174
|
+
box: my_base_box
|
175
|
+
# username is based on what is configured in your box/ami
|
176
|
+
username: ubuntu
|
177
|
+
customize:
|
178
|
+
access_key_id: "AKKJHG659868LHGLH"
|
179
|
+
secret_access_key: "G8t7o+6HLG876JGF/58"
|
180
|
+
ami: ami-7865ab765d
|
181
|
+
instance_type: t2.micro
|
182
|
+
# more customisation can go here, based on what the vagrant provider supports
|
183
|
+
#security-groups: []
|
184
|
+
```
|
185
|
+
|
186
|
+
*Notes*
|
187
|
+
|
188
|
+
* 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 suite of tests or change the name, you'll need to adapt my example accordingly.
|
189
|
+
* serverspec test files *must* be named `_spec.rb`
|
190
|
+
* Since I'm using Vagrant, my `box` definitions refer to Vagrant boxes, either standard, published boxes available from <http://atlas.hashicorp.com/boxes> or custom-created boxes (perhaps using [Packer][packer] and [bento][bento]), in which case you'll need to provide the url in `box_url`.
|
191
|
+
|
192
|
+
[Serverspec]: http://serverspec.org
|
193
|
+
[packer]: https://packer.io
|
194
|
+
[bento]: https://github.com/chef/bento
|
195
|
+
|
data/kitchen-ansible.gemspec
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$:.unshift File.expand_path('../lib', __FILE__)
|
4
|
-
require 'kitchen-ansible/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "kitchen-ansible"
|
8
|
-
s.license = "Apache-2.0"
|
9
|
-
s.version = Kitchen::Ansible::VERSION
|
10
|
-
s.authors = ["Neill Turner"]
|
11
|
-
s.email = ["neillwturner@gmail.com"]
|
12
|
-
s.homepage = "https://github.com/neillturner/kitchen-ansible"
|
13
|
-
s.summary = "ansible provisioner for test-kitchen"
|
14
|
-
candidates = Dir.glob("{lib}/**/*") + ['README.md', 'provisioner_options.md', 'kitchen-ansible.gemspec']
|
15
|
-
s.files = candidates.sort
|
16
|
-
s.platform = Gem::Platform::RUBY
|
17
|
-
s.require_paths = ['lib']
|
18
|
-
s.rubyforge_project = '[none]'
|
19
|
-
s.description = <<-EOF
|
20
|
-
== DESCRIPTION:
|
21
|
-
|
22
|
-
Ansible Provisioner for Test Kitchen
|
23
|
-
|
24
|
-
== FEATURES:
|
25
|
-
|
26
|
-
Supports running ansible-playbook
|
27
|
-
|
28
|
-
EOF
|
29
|
-
s.add_runtime_dependency 'test-kitchen'
|
30
|
-
|
31
|
-
s.add_development_dependency 'rspec'
|
32
|
-
s.add_development_dependency 'pry'
|
33
|
-
s.add_development_dependency 'rake'
|
34
|
-
s.add_runtime_dependency 'librarian-ansible'
|
35
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
require 'kitchen-ansible/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "kitchen-ansible"
|
8
|
+
s.license = "Apache-2.0"
|
9
|
+
s.version = Kitchen::Ansible::VERSION
|
10
|
+
s.authors = ["Neill Turner"]
|
11
|
+
s.email = ["neillwturner@gmail.com"]
|
12
|
+
s.homepage = "https://github.com/neillturner/kitchen-ansible"
|
13
|
+
s.summary = "ansible provisioner for test-kitchen"
|
14
|
+
candidates = Dir.glob("{lib}/**/*") + ['README.md', 'provisioner_options.md', 'kitchen-ansible.gemspec']
|
15
|
+
s.files = candidates.sort
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
s.rubyforge_project = '[none]'
|
19
|
+
s.description = <<-EOF
|
20
|
+
== DESCRIPTION:
|
21
|
+
|
22
|
+
Ansible Provisioner for Test Kitchen
|
23
|
+
|
24
|
+
== FEATURES:
|
25
|
+
|
26
|
+
Supports running ansible-playbook
|
27
|
+
|
28
|
+
EOF
|
29
|
+
s.add_runtime_dependency 'test-kitchen'
|
30
|
+
|
31
|
+
s.add_development_dependency 'rspec'
|
32
|
+
s.add_development_dependency 'pry'
|
33
|
+
s.add_development_dependency 'rake'
|
34
|
+
s.add_runtime_dependency 'librarian-ansible'
|
35
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Kitchen
|
2
|
-
module Ansible
|
3
|
-
VERSION = "0.0.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Kitchen
|
2
|
+
module Ansible
|
3
|
+
VERSION = "0.0.19"
|
4
|
+
end
|
5
|
+
end
|