ansible_spec 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +53 -0
- data/lib/ansible_spec/load_ansible.rb +69 -0
- data/lib/ansible_spec/version.rb +1 -1
- data/lib/src/Rakefile +2 -1
- data/lib/src/spec/spec_helper.rb +10 -0
- data/spec/case/get_variable/group_all/group_vars/all.yml +6 -0
- data/spec/case/get_variable/group_all/hosts +10 -0
- data/spec/case/get_variable/group_all/roles/test/defaults/main.yml +4 -0
- data/spec/case/get_variable/group_all/site.yml +13 -0
- data/spec/case/get_variable/group_each_vars/group_vars/all.yml +6 -0
- data/spec/case/get_variable/group_each_vars/group_vars/group1.yml +4 -0
- data/spec/case/get_variable/group_each_vars/hosts +10 -0
- data/spec/case/get_variable/group_each_vars/site.yml +13 -0
- data/spec/case/get_variable/group_host_playbook/group_vars/all.yml +6 -0
- data/spec/case/get_variable/group_host_playbook/group_vars/group1.yml +4 -0
- data/spec/case/get_variable/group_host_playbook/host_vars/192.168.1.1.yml +3 -0
- data/spec/case/get_variable/group_host_playbook/host_vars/192.168.1.2.yml +3 -0
- data/spec/case/get_variable/group_host_playbook/hosts +10 -0
- data/spec/case/get_variable/group_host_playbook/site.yml +19 -0
- data/spec/case/get_variable/group_host_playbook_role/group_vars/all.yml +6 -0
- data/spec/case/get_variable/group_host_playbook_role/group_vars/group1.yml +4 -0
- data/spec/case/get_variable/group_host_playbook_role/host_vars/192.168.1.1.yml +3 -0
- data/spec/case/get_variable/group_host_playbook_role/host_vars/192.168.1.2.yml +3 -0
- data/spec/case/get_variable/group_host_playbook_role/hosts +10 -0
- data/spec/case/get_variable/group_host_playbook_role/roles/test/vars/main.yml +1 -0
- data/spec/case/get_variable/group_host_playbook_role/site.yml +19 -0
- data/spec/case/get_variable/host_vars/host_vars/192.168.1.1.yml +3 -0
- data/spec/case/get_variable/host_vars/host_vars/192.168.1.2.yml +3 -0
- data/spec/case/get_variable/host_vars/hosts +10 -0
- data/spec/case/get_variable/host_vars/site.yml +13 -0
- data/spec/case/get_variable/playbook_only/hosts +10 -0
- data/spec/case/get_variable/playbook_only/site.yml +19 -0
- data/spec/case/get_variable/roles_default/hosts +10 -0
- data/spec/case/get_variable/roles_default/roles/test/defaults/main.yml +4 -0
- data/spec/case/get_variable/roles_default/site.yml +13 -0
- data/spec/get_variable_spec.rb +227 -0
- data/spec/inventory_parameters_spec.rb +2 -2
- data/spec/load_ansible_spec.rb +4 -4
- metadata +64 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d122ed3ab0a82c97610d92c4003e312c9b840da8
|
4
|
+
data.tar.gz: a5aa9f19132d94f6a71a29dd5757fc1656ed5132
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2032946eab61911a11307e40295d3264a313ae3e447bb44df3a93e35064f72ff5135051192cb7d0a25ffd575c8ab6860ef42088f1a425127958f0f8abc23dda
|
7
|
+
data.tar.gz: 27fcb234ef270985b4111e04c245bc890bd8a2d1b448e81085eb7cfef1e708322e68eae50cf8b759e3167eae35a846f63bdc81360040cb2ab1a47798d1ea22f3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# v0.2.8
|
2
|
+
- Merge [#60 Support ansible variable in playbook partially](https://github.com/volanja/ansible_spec/pull/60) by [okamototk](https://github.com/okamototk)
|
3
|
+
|
1
4
|
# v0.2.7
|
2
5
|
- Fix [#55 Connection fails where dynamic inventory has basic host list](https://github.com/volanja/ansible_spec/issues/55) by [temyers](https://github.com/temyers)
|
3
6
|
- Merge [#59 Issue55 fail dynamic inventory](https://github.com/volanja/ansible_spec/pull/59)
|
data/README.md
CHANGED
@@ -126,6 +126,59 @@ databases
|
|
126
126
|
echo '{"databases": {"hosts": ["host1.example.com", "host2.example.com"],"vars":{"a": true}}}'
|
127
127
|
```
|
128
128
|
|
129
|
+
## Variables
|
130
|
+
|
131
|
+
Ansible variables supported by following condition.
|
132
|
+
|
133
|
+
* Playbook's variables are supported. If same variable is defined in different places,
|
134
|
+
priority follows [Ansible order](http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable).
|
135
|
+
* Variables defined main.yml in role's tasks are not supported.
|
136
|
+
* Inventry variables are not supported.
|
137
|
+
* Facts are not supported.
|
138
|
+
|
139
|
+
### Sample
|
140
|
+
|
141
|
+
Support variables are in site.yml, group_vars, host_vars, roles.
|
142
|
+
|
143
|
+
```
|
144
|
+
├── site.yml
|
145
|
+
├── group_vars
|
146
|
+
│ ├── all.yml
|
147
|
+
│ ├── dbserver.yml
|
148
|
+
│ └── webserver.yml
|
149
|
+
├── host_vars
|
150
|
+
│ ├── 192.168.1.1.yml
|
151
|
+
│ └── 192.168.1.2.yml
|
152
|
+
└── roles
|
153
|
+
├── apaches
|
154
|
+
│ └── vars
|
155
|
+
│ └── main.yml
|
156
|
+
└── mariadb
|
157
|
+
└── vars
|
158
|
+
└── main.yml
|
159
|
+
|
160
|
+
```
|
161
|
+
|
162
|
+
#### Define variable(site.yml)
|
163
|
+
|
164
|
+
|
165
|
+
```
|
166
|
+
- name: Ansible-Variable-Sample
|
167
|
+
hosts: webserver.yml
|
168
|
+
user: root
|
169
|
+
vars:
|
170
|
+
- www_port: 8080
|
171
|
+
roles:
|
172
|
+
- nginx
|
173
|
+
```
|
174
|
+
|
175
|
+
#### Spec file(roles/nginx/spec/nginx_spec.rb)
|
176
|
+
|
177
|
+
```
|
178
|
+
describe port(property['www_port']) do
|
179
|
+
it { should be_listening }
|
180
|
+
end
|
181
|
+
```
|
129
182
|
|
130
183
|
# Sample
|
131
184
|
## Directory
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'hostlist_expression'
|
2
2
|
require 'oj'
|
3
3
|
require 'open3'
|
4
|
+
require 'yaml'
|
4
5
|
|
5
6
|
module AnsibleSpec
|
6
7
|
# param: inventory file of Ansible
|
@@ -277,6 +278,7 @@ module AnsibleSpec
|
|
277
278
|
hosts = load_targets(inventoryfile)
|
278
279
|
properties = load_playbook(playbook)
|
279
280
|
properties.each do |var|
|
281
|
+
var["group"] = var["hosts"]
|
280
282
|
if var["hosts"].to_s == "all"
|
281
283
|
var["hosts"] = hosts.values.flatten
|
282
284
|
elsif hosts.has_key?("#{var["hosts"]}")
|
@@ -287,4 +289,71 @@ module AnsibleSpec
|
|
287
289
|
end
|
288
290
|
return properties
|
289
291
|
end
|
292
|
+
|
293
|
+
def self.get_variables(host, group_idx)
|
294
|
+
vars = {}
|
295
|
+
p = self.get_properties
|
296
|
+
|
297
|
+
# roles default
|
298
|
+
p[group_idx]['roles'].each do |role|
|
299
|
+
vars_file = "roles/#{role}/defaults/main.yml"
|
300
|
+
if File.exist?(vars_file)
|
301
|
+
yaml = YAML.load_file(vars_file)
|
302
|
+
if yaml.kind_of?(Hash)
|
303
|
+
vars.merge!(yaml)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
# all group
|
309
|
+
vars_file = 'group_vars/all.yml'
|
310
|
+
if File.exist?(vars_file)
|
311
|
+
yaml = YAML.load_file(vars_file)
|
312
|
+
if yaml.kind_of?(Hash)
|
313
|
+
vars.merge!(yaml)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
# each group vars
|
318
|
+
if p[group_idx].has_key?('group')
|
319
|
+
vars_file = "group_vars/#{p[group_idx]['group']}.yml"
|
320
|
+
if File.exist?(vars_file)
|
321
|
+
yaml = YAML.load_file(vars_file)
|
322
|
+
if yaml.kind_of?(Hash)
|
323
|
+
vars.merge!(yaml)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
# each host vars
|
329
|
+
vars_file = "host_vars/#{host}.yml"
|
330
|
+
if File.exist?(vars_file)
|
331
|
+
yaml = YAML.load_file(vars_file)
|
332
|
+
if yaml.kind_of?(Hash)
|
333
|
+
vars.merge!(yaml)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
# site vars
|
338
|
+
if p[group_idx].has_key?('vars')
|
339
|
+
if p[group_idx]['vars'].kind_of?(Hash)
|
340
|
+
vars.merge!(p[group_idx]['vars'])
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
# roles vars
|
345
|
+
p[group_idx]['roles'].each do |role|
|
346
|
+
vars_file = "roles/#{role}/vars/main.yml"
|
347
|
+
if File.exist?(vars_file)
|
348
|
+
yaml = YAML.load_file(vars_file)
|
349
|
+
if yaml.kind_of?(Hash)
|
350
|
+
vars.merge!(yaml)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
return vars
|
356
|
+
|
357
|
+
end
|
358
|
+
|
290
359
|
end
|
data/lib/ansible_spec/version.rb
CHANGED
data/lib/src/Rakefile
CHANGED
@@ -8,13 +8,14 @@ properties = AnsibleSpec.get_properties
|
|
8
8
|
# {"name"=>"Ansible-Sample-TDD", "hosts"=>[{"name" => "192.168.0.103:22","uri"=>"192.168.0.103","port"=>22, "private_key"=> "~/.ssh/id_rsa"}], "user"=>"root", "roles"=>["nginx", "mariadb"]}
|
9
9
|
|
10
10
|
namespace :serverspec do
|
11
|
-
properties.
|
11
|
+
properties.each_with_index.map do |property, index|
|
12
12
|
property["hosts"].each do |host|
|
13
13
|
desc "Run serverspec for #{property["name"]}"
|
14
14
|
RSpec::Core::RakeTask.new(property["name"].to_sym) do |t|
|
15
15
|
puts "Run serverspec for #{property["name"]} to #{host}"
|
16
16
|
ENV['TARGET_HOST'] = host["uri"]
|
17
17
|
ENV['TARGET_PORT'] = host["port"].to_s
|
18
|
+
ENV['TARGET_GROUP_INDEX'] = index.to_s
|
18
19
|
ENV['TARGET_PRIVATE_KEY'] = host["private_key"]
|
19
20
|
unless host["user"].nil?
|
20
21
|
ENV['TARGET_USER'] = host["user"]
|
data/lib/src/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'serverspec'
|
2
2
|
require 'net/ssh'
|
3
|
+
require 'ansible_spec'
|
3
4
|
|
4
5
|
set :backend, :ssh
|
5
6
|
|
@@ -34,3 +35,12 @@ set :ssh_options, options
|
|
34
35
|
|
35
36
|
# Set PATH
|
36
37
|
# set :path, '/sbin:/usr/local/sbin:$PATH'
|
38
|
+
|
39
|
+
#
|
40
|
+
# Set ansible variables to serverspec property
|
41
|
+
#
|
42
|
+
|
43
|
+
group_idx = ENV['TARGET_GROUP_INDEX'].to_i
|
44
|
+
|
45
|
+
vars = AnsibleSpec.get_variables(host, group_idx)
|
46
|
+
set_property vars
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- name: group1
|
2
|
+
hosts: group1
|
3
|
+
connection: local
|
4
|
+
vars:
|
5
|
+
site_var: "site"
|
6
|
+
role_var: "site"
|
7
|
+
roles:
|
8
|
+
- test
|
9
|
+
- test/nested
|
10
|
+
|
11
|
+
- name: group2
|
12
|
+
hosts: group2
|
13
|
+
connection: local
|
14
|
+
vars:
|
15
|
+
site_var: "site"
|
16
|
+
role_var: "site"
|
17
|
+
roles:
|
18
|
+
- test
|
19
|
+
- test/nested
|
@@ -0,0 +1 @@
|
|
1
|
+
role_var: "role"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- name: group1
|
2
|
+
hosts: group1
|
3
|
+
connection: local
|
4
|
+
vars:
|
5
|
+
site_var: "site"
|
6
|
+
role_var: "site"
|
7
|
+
roles:
|
8
|
+
- test
|
9
|
+
- test/nested
|
10
|
+
|
11
|
+
- name: group2
|
12
|
+
hosts: group2
|
13
|
+
connection: local
|
14
|
+
vars:
|
15
|
+
site_var: "site"
|
16
|
+
role_var: "site"
|
17
|
+
roles:
|
18
|
+
- test
|
19
|
+
- test/nested
|
@@ -0,0 +1,19 @@
|
|
1
|
+
- name: group1
|
2
|
+
hosts: group1
|
3
|
+
connection: local
|
4
|
+
vars:
|
5
|
+
site_var: "site"
|
6
|
+
role_var: "site"
|
7
|
+
roles:
|
8
|
+
- test
|
9
|
+
- test/nested
|
10
|
+
|
11
|
+
- name: group2
|
12
|
+
hosts: group2
|
13
|
+
connection: local
|
14
|
+
vars:
|
15
|
+
site_var: "site"
|
16
|
+
role_var: "site"
|
17
|
+
roles:
|
18
|
+
- test
|
19
|
+
- test/nested
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'fileutils'
|
3
|
+
require 'ansible_spec'
|
4
|
+
|
5
|
+
describe "get_variablesの実行" do
|
6
|
+
context 'Correct operation : roles default' do
|
7
|
+
before do
|
8
|
+
@current_dir = Dir.pwd()
|
9
|
+
Dir.chdir('spec/case/get_variable/roles_default/')
|
10
|
+
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'res is hash' do
|
14
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'exist 3 pair in Hash' do
|
18
|
+
expect(@res.length).to eq 3
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'exist each pair' do
|
22
|
+
expect(@res).to include({'role_var' => 'role_var in roles default'},
|
23
|
+
{'site_var' => 'site_var in roles default'},
|
24
|
+
{'host_var'=>'host_var in roles default'},
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
after do
|
29
|
+
Dir.chdir(@current_dir)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'Correct operation : all groups' do
|
34
|
+
before do
|
35
|
+
@current_dir = Dir.pwd()
|
36
|
+
Dir.chdir('spec/case/get_variable/group_all/')
|
37
|
+
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'res is hash' do
|
41
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'exist 5 pair in Hash' do
|
45
|
+
expect(@res.length).to eq 5
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'exist each pair' do
|
49
|
+
expect(@res).to include({'role_var' => 'group all'},
|
50
|
+
{'site_var' => 'group all'},
|
51
|
+
{'host_var'=>'group all'},
|
52
|
+
{'group_var'=>'group all'},
|
53
|
+
{'group_all_var'=>'group all'}
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
after do
|
58
|
+
Dir.chdir(@current_dir)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'Correct operation : each group vars' do
|
63
|
+
before do
|
64
|
+
@current_dir = Dir.pwd()
|
65
|
+
Dir.chdir('spec/case/get_variable/group_each_vars/')
|
66
|
+
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'res is hash' do
|
70
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'exist 5 pair in Hash' do
|
74
|
+
expect(@res.length).to eq 5
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'exist each pair' do
|
78
|
+
expect(@res).to include({'role_var' => 'group1'},
|
79
|
+
{'site_var' => 'group1'},
|
80
|
+
{'host_var'=>'group1'},
|
81
|
+
{'group_var'=>'group1'},
|
82
|
+
{'group_all_var'=>'group all'}
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
after do
|
87
|
+
Dir.chdir(@current_dir)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'Correct operation : host_vars' do
|
92
|
+
before do
|
93
|
+
@current_dir = Dir.pwd()
|
94
|
+
Dir.chdir('spec/case/get_variable/host_vars/')
|
95
|
+
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'res is hash' do
|
99
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'exist 3 pair in Hash' do
|
103
|
+
expect(@res.length).to eq 3
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'exist each pair' do
|
107
|
+
expect(@res).to include({'role_var' => 'host role_var'}, # in host_var/192.168.1.1.yml
|
108
|
+
{'site_var' => 'host site_var'}, # in host_var/192.168.1.1.yml
|
109
|
+
{'host_var'=>'host 192.168.1.1'}, # in host_var/192.168.1.1.yml
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
after do
|
114
|
+
Dir.chdir(@current_dir)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'Correct operation : host_vars' do
|
119
|
+
before do
|
120
|
+
@current_dir = Dir.pwd()
|
121
|
+
Dir.chdir('spec/case/get_variable/host_vars/')
|
122
|
+
@res = AnsibleSpec.get_variables('192.168.1.2', 1)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'res is hash' do
|
126
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'exist 3 pair in Hash' do
|
130
|
+
expect(@res.length).to eq 3
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'exist each pair' do
|
134
|
+
expect(@res).to include({'role_var' => 'host role_var'}, # in host_var/192.168.1.2.yml
|
135
|
+
{'site_var' => 'host site_var'}, # in host_var/192.168.1.2.yml
|
136
|
+
{'host_var'=>'host 192.168.1.2'}, # in host_var/192.168.1.2.yml
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
after do
|
141
|
+
Dir.chdir(@current_dir)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'Correct operation : playbook only' do
|
146
|
+
before do
|
147
|
+
@current_dir = Dir.pwd()
|
148
|
+
Dir.chdir('spec/case/get_variable/playbook_only/')
|
149
|
+
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'res is hash' do
|
153
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'exist 2 pair in Hash' do
|
157
|
+
expect(@res.length).to eq 2
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'exist each pair' do
|
161
|
+
expect(@res).to include({'role_var' => 'site'},
|
162
|
+
{'site_var' => 'site'})
|
163
|
+
end
|
164
|
+
|
165
|
+
after do
|
166
|
+
Dir.chdir(@current_dir)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'Correct operation : playbook & group_var & host_var' do
|
171
|
+
before do
|
172
|
+
@current_dir = Dir.pwd()
|
173
|
+
Dir.chdir('spec/case/get_variable/group_host_playbook/')
|
174
|
+
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'res is hash' do
|
178
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'exist 5 pair in Hash' do
|
182
|
+
expect(@res.length).to eq 5
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'exist each pair' do
|
186
|
+
expect(@res).to include({'role_var' => 'site'}, # site.yml
|
187
|
+
{'site_var' => 'site'}, # site.yml
|
188
|
+
{'host_var'=>'host 192.168.1.1'}, # in host_var/192.168.1.1.yml
|
189
|
+
{'group_var'=>'group1'}, # in group_var/all.yml
|
190
|
+
{'group_all_var'=>'group all'} # in group_var/all.yml
|
191
|
+
)
|
192
|
+
end
|
193
|
+
|
194
|
+
after do
|
195
|
+
Dir.chdir(@current_dir)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'Correct operation : playbook & group_var & host_var & variable in role' do
|
200
|
+
before do
|
201
|
+
@current_dir = Dir.pwd()
|
202
|
+
Dir.chdir('spec/case/get_variable/group_host_playbook_role/')
|
203
|
+
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'res is hash' do
|
207
|
+
expect(@res.instance_of?(Hash)).to be_truthy
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'exist 5 pair in Hash' do
|
211
|
+
expect(@res.length).to eq 5
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'exist each pair' do
|
215
|
+
expect(@res).to include({'role_var' => 'role'}, # in roles/test/vars/main.yml
|
216
|
+
{'site_var' => 'site'}, # site.yml
|
217
|
+
{'host_var'=>'host 192.168.1.1'}, # in host_var/192.168.1.1.yml
|
218
|
+
{'group_var'=>'group1'}, # in group_var/all.yml
|
219
|
+
{'group_all_var'=>'group all'} # in group_var/all.yml
|
220
|
+
)
|
221
|
+
end
|
222
|
+
|
223
|
+
after do
|
224
|
+
Dir.chdir(@current_dir)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
@@ -142,8 +142,8 @@ describe "get_propertiesの実行" do
|
|
142
142
|
expect(@res[0].instance_of?(Hash)).to be_truthy
|
143
143
|
end
|
144
144
|
|
145
|
-
it 'check
|
146
|
-
expect(@res[0].length).to eq
|
145
|
+
it 'check 5 group' do
|
146
|
+
expect(@res[0].length).to eq 5
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'exist name' do
|
data/spec/load_ansible_spec.rb
CHANGED
@@ -1191,8 +1191,8 @@ EOF
|
|
1191
1191
|
expect(@res[0].instance_of?(Hash)).to be_truthy
|
1192
1192
|
end
|
1193
1193
|
|
1194
|
-
it 'check
|
1195
|
-
expect(@res[0].length).to eq
|
1194
|
+
it 'check 5 group' do
|
1195
|
+
expect(@res[0].length).to eq 5
|
1196
1196
|
end
|
1197
1197
|
|
1198
1198
|
it 'exist name' do
|
@@ -1276,8 +1276,8 @@ EOF
|
|
1276
1276
|
expect(@res[0].instance_of?(Hash)).to be_truthy
|
1277
1277
|
end
|
1278
1278
|
|
1279
|
-
it 'check
|
1280
|
-
expect(@res[0].length).to eq
|
1279
|
+
it 'check 5 group' do
|
1280
|
+
expect(@res[0].length).to eq 5
|
1281
1281
|
end
|
1282
1282
|
|
1283
1283
|
it 'exist name' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansible_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- volanja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -133,10 +133,41 @@ files:
|
|
133
133
|
- lib/src/.ansiblespec
|
134
134
|
- lib/src/Rakefile
|
135
135
|
- lib/src/spec/spec_helper.rb
|
136
|
+
- spec/case/get_variable/group_all/group_vars/all.yml
|
137
|
+
- spec/case/get_variable/group_all/hosts
|
138
|
+
- spec/case/get_variable/group_all/roles/test/defaults/main.yml
|
139
|
+
- spec/case/get_variable/group_all/site.yml
|
140
|
+
- spec/case/get_variable/group_each_vars/group_vars/all.yml
|
141
|
+
- spec/case/get_variable/group_each_vars/group_vars/group1.yml
|
142
|
+
- spec/case/get_variable/group_each_vars/hosts
|
143
|
+
- spec/case/get_variable/group_each_vars/site.yml
|
144
|
+
- spec/case/get_variable/group_host_playbook/group_vars/all.yml
|
145
|
+
- spec/case/get_variable/group_host_playbook/group_vars/group1.yml
|
146
|
+
- spec/case/get_variable/group_host_playbook/host_vars/192.168.1.1.yml
|
147
|
+
- spec/case/get_variable/group_host_playbook/host_vars/192.168.1.2.yml
|
148
|
+
- spec/case/get_variable/group_host_playbook/hosts
|
149
|
+
- spec/case/get_variable/group_host_playbook/site.yml
|
150
|
+
- spec/case/get_variable/group_host_playbook_role/group_vars/all.yml
|
151
|
+
- spec/case/get_variable/group_host_playbook_role/group_vars/group1.yml
|
152
|
+
- spec/case/get_variable/group_host_playbook_role/host_vars/192.168.1.1.yml
|
153
|
+
- spec/case/get_variable/group_host_playbook_role/host_vars/192.168.1.2.yml
|
154
|
+
- spec/case/get_variable/group_host_playbook_role/hosts
|
155
|
+
- spec/case/get_variable/group_host_playbook_role/roles/test/vars/main.yml
|
156
|
+
- spec/case/get_variable/group_host_playbook_role/site.yml
|
157
|
+
- spec/case/get_variable/host_vars/host_vars/192.168.1.1.yml
|
158
|
+
- spec/case/get_variable/host_vars/host_vars/192.168.1.2.yml
|
159
|
+
- spec/case/get_variable/host_vars/hosts
|
160
|
+
- spec/case/get_variable/host_vars/site.yml
|
161
|
+
- spec/case/get_variable/playbook_only/hosts
|
162
|
+
- spec/case/get_variable/playbook_only/site.yml
|
163
|
+
- spec/case/get_variable/roles_default/hosts
|
164
|
+
- spec/case/get_variable/roles_default/roles/test/defaults/main.yml
|
165
|
+
- spec/case/get_variable/roles_default/site.yml
|
136
166
|
- spec/commands_spec.rb
|
137
167
|
- spec/dependency_spec.rb
|
138
168
|
- spec/dynamic_inventory_spec.rb
|
139
169
|
- spec/ec2_dynamic_inventory_spec.rb
|
170
|
+
- spec/get_variable_spec.rb
|
140
171
|
- spec/inventory_parameters_spec.rb
|
141
172
|
- spec/load_ansible_spec.rb
|
142
173
|
- spec/spec_helper.rb
|
@@ -167,10 +198,41 @@ specification_version: 4
|
|
167
198
|
summary: Ansible Config Parser for Serverspec. Run test Multi Role and Multi Host
|
168
199
|
by Ansible Configuration
|
169
200
|
test_files:
|
201
|
+
- spec/case/get_variable/group_all/group_vars/all.yml
|
202
|
+
- spec/case/get_variable/group_all/hosts
|
203
|
+
- spec/case/get_variable/group_all/roles/test/defaults/main.yml
|
204
|
+
- spec/case/get_variable/group_all/site.yml
|
205
|
+
- spec/case/get_variable/group_each_vars/group_vars/all.yml
|
206
|
+
- spec/case/get_variable/group_each_vars/group_vars/group1.yml
|
207
|
+
- spec/case/get_variable/group_each_vars/hosts
|
208
|
+
- spec/case/get_variable/group_each_vars/site.yml
|
209
|
+
- spec/case/get_variable/group_host_playbook/group_vars/all.yml
|
210
|
+
- spec/case/get_variable/group_host_playbook/group_vars/group1.yml
|
211
|
+
- spec/case/get_variable/group_host_playbook/host_vars/192.168.1.1.yml
|
212
|
+
- spec/case/get_variable/group_host_playbook/host_vars/192.168.1.2.yml
|
213
|
+
- spec/case/get_variable/group_host_playbook/hosts
|
214
|
+
- spec/case/get_variable/group_host_playbook/site.yml
|
215
|
+
- spec/case/get_variable/group_host_playbook_role/group_vars/all.yml
|
216
|
+
- spec/case/get_variable/group_host_playbook_role/group_vars/group1.yml
|
217
|
+
- spec/case/get_variable/group_host_playbook_role/host_vars/192.168.1.1.yml
|
218
|
+
- spec/case/get_variable/group_host_playbook_role/host_vars/192.168.1.2.yml
|
219
|
+
- spec/case/get_variable/group_host_playbook_role/hosts
|
220
|
+
- spec/case/get_variable/group_host_playbook_role/roles/test/vars/main.yml
|
221
|
+
- spec/case/get_variable/group_host_playbook_role/site.yml
|
222
|
+
- spec/case/get_variable/host_vars/host_vars/192.168.1.1.yml
|
223
|
+
- spec/case/get_variable/host_vars/host_vars/192.168.1.2.yml
|
224
|
+
- spec/case/get_variable/host_vars/hosts
|
225
|
+
- spec/case/get_variable/host_vars/site.yml
|
226
|
+
- spec/case/get_variable/playbook_only/hosts
|
227
|
+
- spec/case/get_variable/playbook_only/site.yml
|
228
|
+
- spec/case/get_variable/roles_default/hosts
|
229
|
+
- spec/case/get_variable/roles_default/roles/test/defaults/main.yml
|
230
|
+
- spec/case/get_variable/roles_default/site.yml
|
170
231
|
- spec/commands_spec.rb
|
171
232
|
- spec/dependency_spec.rb
|
172
233
|
- spec/dynamic_inventory_spec.rb
|
173
234
|
- spec/ec2_dynamic_inventory_spec.rb
|
235
|
+
- spec/get_variable_spec.rb
|
174
236
|
- spec/inventory_parameters_spec.rb
|
175
237
|
- spec/load_ansible_spec.rb
|
176
238
|
- spec/spec_helper.rb
|