ansible_spec 0.3.1 → 0.3.2

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
  SHA256:
3
- metadata.gz: 2d87ec24d89e985e499037877255f902b7eb7345a4fd4d4af1d262c55287ef9a
4
- data.tar.gz: 819cc6ef8696ac2dbd09026e00ef05ffea63ccb6ca59a54cea75bb54dce0981d
3
+ metadata.gz: d77ce9fa38453ab6f652cc6c20a79509c722d615790cb49b59ec8e37154aad7b
4
+ data.tar.gz: 27384622e2d91ad928ee5b37fa061efa3b80af5baad5b887823ec3df7e83dded
5
5
  SHA512:
6
- metadata.gz: 7f59e840375f84b5df3df071cc1e9687734038556c3a6a888c7f8529f710130f337db4161dad2234ef787f0c493bbc88ce2256c19e95cd8e6052d37be478dc8b
7
- data.tar.gz: 01d38a3d50b2f704351ae2c9f0e33c18d101b85f5c049d6126d66f485e6132634ef6936a3ca7059d7ff53f371cf8296b85f3d4cd2c4d916574850b785c1b445a
6
+ metadata.gz: 2591637e35a8fa5fe8f2add17e24d5f32844030d9fd1f268ec4a0e607bb4f2500ef8a75c166c337d20c8e97c8db979dc1bdf317f64f5f93095493699bef37665
7
+ data.tar.gz: e1124d4328dc3430545f94a87306fc9148f3b91bc5074d84180edac293966115b15794e5ecd142335a2c972415143f7893bf6516d951bfb4b4ffd1f2855d561d
@@ -7,9 +7,9 @@ rvm:
7
7
  - 2.1.10
8
8
  - 2.2.10
9
9
  - 2.3.8
10
- - 2.4.9
11
- - 2.5.7
12
- - 2.6.5
13
- - 2.7.0
10
+ - 2.4.10
11
+ - 2.5.8
12
+ - 2.6.6
13
+ - 2.7.1
14
14
  script:
15
15
  - rspec spec
@@ -1,3 +1,6 @@
1
+ # v0.3.2
2
+ - Merge [#135 Fix wrong index by empty group](https://github.com/volanja/ansible_spec/pull/135) by [mamiya312](https://github.com/mamiya312)
3
+
1
4
  # v0.3.1
2
5
  - Fix [#126 no implicit conversion of nil into Array Error when process get_parent](https://github.com/volanja/ansible_spec/issues/126) by [shogos3](https://github.com/shogos3)
3
6
 
@@ -516,7 +516,7 @@ module AnsibleSpec
516
516
 
517
517
  def self.get_variables(host, group_idx, hosts=nil)
518
518
  vars = {}
519
- p = self.get_properties
519
+ p = self.get_properties.compact.reject{|e| e["hosts"].length == 0}
520
520
 
521
521
  # roles default
522
522
  p[group_idx]['roles'].each do |role|
@@ -1,3 +1,3 @@
1
1
  module AnsibleSpec
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -0,0 +1,2 @@
1
+ ---
2
+ group_a_var: hoge
@@ -0,0 +1,2 @@
1
+ ---
2
+ group_b_var: fuga
@@ -0,0 +1,3 @@
1
+ [group_a]
2
+ [group_b]
3
+ localhost.localdomain ansible_ssh_private_key_file=~/.ssh/id_rsa
@@ -0,0 +1,9 @@
1
+ ---
2
+ - name: playbook_a
3
+ hosts: group_a
4
+ roles:
5
+ - role_a
6
+ - name: playbook_b
7
+ hosts: group_b
8
+ roles:
9
+ - role_b
@@ -362,6 +362,45 @@ describe "get_variablesの実行" do
362
362
  end
363
363
  end
364
364
 
365
+ # Fixed a problem that there is a gap between Index passed from Rakefile when empty group exists. by #135
366
+ # cat hosts
367
+ # [group_a] #no host
368
+ # [group_b]
369
+ # localhost.localdomain ansible_ssh_private_key_file=~/.ssh/id_rsa
370
+
371
+ context 'Correct operation : empty group PR #135 ' do
372
+ before do
373
+ @current_dir = Dir.pwd()
374
+ Dir.chdir('spec/case/get_variable/empty_group')
375
+ ENV["PLAYBOOK"] = 'site.yml'
376
+ ENV["INVENTORY"] = 'hosts'
377
+ ENV["VARS_DIRS_PATH"] = ''
378
+ @res = AnsibleSpec.get_variables("localhost.localdomain", 0)
379
+ end
380
+
381
+ it 'res is hash' do
382
+ expect(@res.instance_of?(Hash)).to be_truthy
383
+ end
384
+
385
+ it 'exist 1 pair in Hash' do
386
+ expect(@res.length).to eq 1
387
+ end
388
+
389
+ it 'get correct variable' do
390
+ expect(@res).to eq("group_b_var" => "fuga")
391
+ end
392
+
393
+ it 'not get incorrect variables' do
394
+ expect(@res).not_to eq("group_a_var" => "hoge")
395
+ end
396
+
397
+ after do
398
+ ENV.delete('PLAYBOOK')
399
+ ENV.delete('INVENTORY')
400
+ ENV.delete('VARS_DIRS_PATH')
401
+ Dir.chdir(@current_dir)
402
+ end
403
+ end
365
404
  end
366
405
 
367
406
  describe "get_hash_behaviourの実行" 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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - volanja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-12 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -190,6 +190,10 @@ files:
190
190
  - spec/case/get_variable/deep_merge/hosts
191
191
  - spec/case/get_variable/deep_merge/roles/test/defaults/main.yml
192
192
  - spec/case/get_variable/deep_merge/site.yml
193
+ - spec/case/get_variable/empty_group/group_vars/group_a.yml
194
+ - spec/case/get_variable/empty_group/group_vars/group_b.yml
195
+ - spec/case/get_variable/empty_group/hosts
196
+ - spec/case/get_variable/empty_group/site.yml
193
197
  - spec/case/get_variable/group_all/group_vars/all.yml
194
198
  - spec/case/get_variable/group_all/hosts
195
199
  - spec/case/get_variable/group_all/roles/test/defaults/main.yml
@@ -379,6 +383,10 @@ test_files:
379
383
  - spec/case/get_variable/deep_merge/hosts
380
384
  - spec/case/get_variable/deep_merge/roles/test/defaults/main.yml
381
385
  - spec/case/get_variable/deep_merge/site.yml
386
+ - spec/case/get_variable/empty_group/group_vars/group_a.yml
387
+ - spec/case/get_variable/empty_group/group_vars/group_b.yml
388
+ - spec/case/get_variable/empty_group/hosts
389
+ - spec/case/get_variable/empty_group/site.yml
382
390
  - spec/case/get_variable/group_all/group_vars/all.yml
383
391
  - spec/case/get_variable/group_all/hosts
384
392
  - spec/case/get_variable/group_all/roles/test/defaults/main.yml