kitchen-ansible 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,3 +43,78 @@ platforms:
43
43
  - ['forwarded_port', {guest: 8080, host: 8080}]
44
44
  - [ 'private_network', { ip: '192.168.33.11' } ]
45
45
  ```
46
+
47
+ ## Test-Kitchen/Ansible/Serverspec
48
+
49
+ In the root directory for your Ansible role:
50
+
51
+ Create a `.kitchen.yml`, much like one the described above:
52
+
53
+ ---
54
+ driver:
55
+ name: vagrant
56
+
57
+ provisioner:
58
+ name: ansible_playbook
59
+ playbook: default.yml
60
+ ansible_yum_repo: "https://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm"
61
+ ansible_verbose: true
62
+ ansible_verbosity: 3
63
+ hosts: all
64
+
65
+ platforms:
66
+ - name: ubuntu-12.04
67
+ driver_config:
68
+ box: ubuntu/precise32
69
+ - name: centos-7
70
+ driver_config:
71
+ box: chef/centos-7.0
72
+
73
+ suites:
74
+ - name: default
75
+
76
+ Then for serverspec:
77
+
78
+ mkdir -p test/integration/default/serverspec/localhost
79
+ echo "require 'serverspec'" >> test/integration/default/serverspec/spec_helper.rb
80
+ echo "set :backend, :exec" >> test/integration/default/serverspec/spec_helper.rb
81
+
82
+ Create a basic playbook `test/integration/default.yml` so that kitchen can use your role (this should include any dependencies for your role):
83
+
84
+ ---
85
+ - name: wrapper playbook for kitchen testing "my_role"
86
+ hosts: localhost
87
+ roles:
88
+ - my_role
89
+
90
+ Create your serverspec tests in `test/integration/default/serverspec/localhost/my_roles_spec.rb`:
91
+
92
+ require 'spec_helper'
93
+
94
+ if os[:family] == 'ubuntu'
95
+ describe '/etc/lsb-release' do
96
+ it "exists" do
97
+ expect(file('/etc/lsb-release').to be_file
98
+ end
99
+ end
100
+ end
101
+
102
+ if os[:family] == 'redhat'
103
+ describe '/etc/redhat-release' do
104
+ it "exists" do
105
+ expect(file('/etc/redhat-release')).to be_file
106
+ end
107
+ end
108
+ end
109
+
110
+ *Notes*
111
+
112
+ * 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.
113
+ * serverspec test files *must* be named `_spec.rb`
114
+ * 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`.
115
+ * This could be adapted to using Openstack/AWS/whatever VMs as supported by Vagrant.
116
+
117
+ [Serverspec]: http://serverspec.org
118
+ [packer]: https://packer.io
119
+ [bento]: https://github.com/chef/bento
120
+
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Ansible
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
@@ -84,7 +84,8 @@ module Kitchen
84
84
  default_config :requirements_path, false
85
85
  default_config :ansible_verbose, false
86
86
  default_config :ansible_verbosity, 1
87
- default_config :ansible_noop, false # what is ansible equivalent of dry_run???? ##JMC: I think it's [--check mode](http://docs.ansible.com/playbooks_checkmode.html) TODO: Look into this...
87
+ default_config :ansible_check, false
88
+ default_config :ansible_diff, false
88
89
  default_config :ansible_platform, ''
89
90
  default_config :update_package_repos, true
90
91
 
@@ -314,6 +315,7 @@ module Kitchen
314
315
  "-M #{File.join(config[:root_path], 'modules')}",
315
316
  ansible_verbose_flag,
316
317
  ansible_check_flag,
318
+ ansible_diff_flag,
317
319
  extra_vars,
318
320
  tags,
319
321
  "#{File.join(config[:root_path], File.basename(config[:playbook]))}",
@@ -401,6 +403,10 @@ module Kitchen
401
403
  config[:ansible_check] ? '--check' : nil
402
404
  end
403
405
 
406
+ def ansible_diff_flag
407
+ config[:ansible_diff] ? '--diff' : nil
408
+ end
409
+
404
410
  def ansible_platform
405
411
  config[:ansible_platform].to_s.downcase
406
412
  end
@@ -20,6 +20,8 @@ playbook | 'site.yml' | playbook for ansible-playbook to run
20
20
  modules_path | | ansible repo manifests directory
21
21
  ansible_verbose| false| Extra information logging
22
22
  ansible_verbosity| 1| Sets the verbosity flag appropriately (e.g.: `1 => '-v', 2 => '-vv', 3 => '-vvv" ...`) Valid values are one of: `1, 2, 3, 4` OR `:info, :warn, :debug, :trace`.
23
+ ansible_check| false| Sets the `--check` flag when running Ansible
24
+ ansible_diff| false| Sets the `--diff` flag when running Ansible
23
25
  update_package_repos| true| update OS repository metadata
24
26
  chef_bootstrap_url |"https://www.getchef.com/chef/install.sh"| the chef (needed for busser to run tests)
25
27
  ansiblefile_path | | Path to Ansiblefile
@@ -40,6 +42,7 @@ The provisioner can be configured globally or per suite, global settings act as
40
42
  require_ansible_repo: true
41
43
  ansible_verbose: true
42
44
  ansible_verbosity: 2
45
+ ansible_diff: true
43
46
 
44
47
  platforms:
45
48
  - name: nocm_ubuntu-12.04
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-27 00:00:00.000000000 Z
12
+ date: 2015-02-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! '== DESCRIPTION:
15
15