ansible_spec 0.2.22 → 0.2.23

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: 3c7c2e8e332c8081556cb66d7f6fbdd97fe61248
4
- data.tar.gz: a8350998cdbf812f4b148ff45fd4904e1c56354f
3
+ metadata.gz: ea92ad1db5c6331ab0f51cb0cc9f8357d6fad5a1
4
+ data.tar.gz: 3529e094be9910fb8acb9c1e3df7661e4e21135e
5
5
  SHA512:
6
- metadata.gz: ffc9bc8b58c2adb1a335e21ec9454d92706ae8c74b9db3b99cce12a52b6aa79f9cf8600cb0f6496b5a68f17fd2278dd8183424b317448c14bade7faf9aab3074
7
- data.tar.gz: 8766b40e4bfb60f1d5c3b61f0f78ed34b3d29d023622bd530f3d1f386e1d3ae193c52205c04b96575e1355f67176452b2024a942362e27f040e576076f4f73bb
6
+ metadata.gz: 4f8121627c3ffb1b2011e8b77d2ef0704b8f64ab59075c2973e7768c7fb26a1c21606332acdb7a6faedc1d4d17be4287abf354de010fc4c72ded2d7db003aa88
7
+ data.tar.gz: ded735c540319da5a2443d9639390f3e0a5d915a5249e410d0295f3f32b99b09bcc6625384d2778784bf8f7484f4f199a6a5c52b6dce9eb2f0a6149927f59d3b
data/.travis.yml CHANGED
@@ -4,8 +4,9 @@ rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
6
  - 2.1.10
7
- - 2.2.6
8
- - 2.3.3
9
- - 2.4.0
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
10
11
  script:
11
12
  - rspec spec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.2.23
2
+ - Merge [#115 Support import_playbook](https://github.com/volanja/ansible_spec/pull/115) by [seiji](https://github.com/seiji)
3
+ - Merge [#113 Make ENV variables override SSH config file options](https://github.com/volanja/ansible_spec/pull/113) by [Jonnymcc](https://github.com/Jonnymcc)
4
+
1
5
  # v0.2.22
2
6
  - Merge [#111 fix sudo directive for after Ansible 1.9](https://github.com/volanja/ansible_spec/pull/111) by [katsuhisa91](https://github.com/katsuhisa91)
3
7
 
data/README.md CHANGED
@@ -155,6 +155,13 @@ Ansible variables supported by following condition.
155
155
  * Inventory variables are not supported.
156
156
  * Facts are not supported.
157
157
 
158
+ ## SSH config priority (from v0.2.23)
159
+
160
+ 1. ENV['SSH_CONFIG_FILE'] (high priority)
161
+ 1. ssh_args( -F "filename") in [ssh_connection] section of ansible.cfg
162
+ 1. user from site.yml
163
+ 1. ~/.ssh/config (low priority)
164
+
158
165
  ### Sample
159
166
 
160
167
  Support variables are in site.yml, group_vars, host_vars, roles.
@@ -277,7 +284,7 @@ sample is [here](https://github.com/volanja/ansible-sample-tdd)
277
284
 
278
285
  ## Playbook
279
286
 
280
- playbook can use `include`
287
+ playbook can use `import_playbook` & `include[DEPRECATION]`
281
288
 
282
289
  ```site.yml
283
290
  - name: Ansible-Sample-TDD
@@ -234,6 +234,10 @@ module AnsibleSpec
234
234
  YAML.load_file(site["include"]).each { |site|
235
235
  properties.push site
236
236
  }
237
+ elsif site.has_key?("import_playbook")
238
+ YAML.load_file(site["import_playbook"]).each { |site|
239
+ properties.push site
240
+ }
237
241
  else
238
242
  properties.push site
239
243
  end
@@ -1,3 +1,3 @@
1
1
  module AnsibleSpec
2
- VERSION = "0.2.22"
2
+ VERSION = "0.2.23"
3
3
  end
@@ -34,15 +34,16 @@ when 'ssh'
34
34
  set :become_password, ENV['BECOME_PASSWORD']
35
35
  end
36
36
 
37
- unless ssh_config_file
38
- options = Net::SSH::Config.for(host)
39
- else
40
- options = Net::SSH::Config.for(host,files=[ssh_config_file])
41
- end
37
+ options = Net::SSH::Config.for(host)
42
38
 
43
- options[:user] ||= ENV['TARGET_USER']
44
- options[:port] ||= ENV['TARGET_PORT']
45
- options[:keys] ||= ENV['TARGET_PRIVATE_KEY']
39
+ options[:user] = ENV['TARGET_USER'] || options[:user]
40
+ options[:port] = ENV['TARGET_PORT'] || options[:port]
41
+ options[:keys] = ENV['TARGET_PRIVATE_KEY'] || options[:keys]
42
+
43
+ if ssh_config_file
44
+ from_config_file = Net::SSH::Config.for(host,files=[ssh_config_file])
45
+ options.merge!(from_config_file)
46
+ end
46
47
 
47
48
  set :host, options[:host_name] || host
48
49
  set :ssh_options, options
@@ -570,22 +570,23 @@ EOF
570
570
  end
571
571
  end
572
572
 
573
- context '正常系(include)' do
574
- require 'yaml'
575
- tmp_pb = 'site.yml'
576
- tmp_inc = 'nginx.yml'
577
- before do
578
- content_pb = <<'EOF'
573
+ %w[include import_playbook].each do |action|
574
+ context "正常系(#{action})" do
575
+ require 'yaml'
576
+ tmp_pb = 'site.yml'
577
+ tmp_inc = 'nginx.yml'
578
+ before do
579
+ content_pb = <<"EOF" # ヒアドキュメント内で変数展開する時は""(double quote)で囲む。
579
580
  - name: Ansible-Sample-TDD
580
581
  hosts: server
581
582
  user: root
582
583
  roles:
583
584
  - mariadb
584
- - include: nginx.yml
585
+ - #{action}: nginx.yml
585
586
  EOF
586
- create_file(tmp_pb,content_pb)
587
+ create_file(tmp_pb,content_pb)
587
588
 
588
- content_inc = <<'EOF'
589
+ content_inc = <<'EOF'
589
590
  - name: Ansible-Nginx
590
591
  hosts: web
591
592
  user: nginx
@@ -598,87 +599,88 @@ EOF
598
599
  roles:
599
600
  - nginx-proxy
600
601
  EOF
601
- create_file(tmp_inc,content_inc)
602
+ create_file(tmp_inc,content_inc)
602
603
 
603
- @res = AnsibleSpec.load_playbook(tmp_pb)
604
- end
604
+ @res = AnsibleSpec.load_playbook(tmp_pb)
605
+ end
605
606
 
606
- it 'res is array' do
607
- expect(@res.instance_of?(Array)).to be_truthy
608
- end
607
+ it 'res is array' do
608
+ expect(@res.instance_of?(Array)).to be_truthy
609
+ end
609
610
 
610
- it 'res has three groups' do
611
- expect(@res.length).to eq 3
612
- end
611
+ it 'res has three groups' do
612
+ expect(@res.length).to eq 3
613
+ end
613
614
 
614
615
 
615
- it 'res is hash' do
616
- expect(@res[0].instance_of?(Hash)).to be_truthy
617
- end
616
+ it 'res is hash' do
617
+ expect(@res[0].instance_of?(Hash)).to be_truthy
618
+ end
618
619
 
619
- it 'check 1 group' do
620
- expect(@res[0].length).to eq 4
621
- end
620
+ it 'check 1 group' do
621
+ expect(@res[0].length).to eq 4
622
+ end
622
623
 
623
- it 'exist name' do
624
- expect(@res[0].key?('name')).to be_truthy
625
- expect(@res[0]['name']).to eq 'Ansible-Sample-TDD'
626
- end
624
+ it 'exist name' do
625
+ expect(@res[0].key?('name')).to be_truthy
626
+ expect(@res[0]['name']).to eq 'Ansible-Sample-TDD'
627
+ end
627
628
 
628
- it 'exist hosts' do
629
- expect(@res[0].key?('hosts')).to be_truthy
630
- expect(@res[0]['hosts']).to eq 'server'
631
- end
629
+ it 'exist hosts' do
630
+ expect(@res[0].key?('hosts')).to be_truthy
631
+ expect(@res[0]['hosts']).to eq 'server'
632
+ end
632
633
 
633
- it 'exist user' do
634
- expect(@res[0].key?('user')).to be_truthy
635
- expect(@res[0]['user']).to eq 'root'
636
- end
634
+ it 'exist user' do
635
+ expect(@res[0].key?('user')).to be_truthy
636
+ expect(@res[0]['user']).to eq 'root'
637
+ end
637
638
 
638
- it 'exist roles' do
639
- expect(@res[0].key?('roles')).to be_truthy
640
- expect(@res[0]['roles'].instance_of?(Array)).to be_truthy
641
- expect(@res[0]['roles'][0]).to eq 'mariadb'
642
- end
639
+ it 'exist roles' do
640
+ expect(@res[0].key?('roles')).to be_truthy
641
+ expect(@res[0]['roles'].instance_of?(Array)).to be_truthy
642
+ expect(@res[0]['roles'][0]).to eq 'mariadb'
643
+ end
643
644
 
644
- # - include: nginx.yml
645
- it 'res is hash' do
646
- expect(@res[1].instance_of?(Hash)).to be_truthy
647
- end
645
+ # - include: nginx.yml
646
+ it 'res is hash' do
647
+ expect(@res[1].instance_of?(Hash)).to be_truthy
648
+ end
648
649
 
649
- it 'check 1 group' do
650
- expect(@res[1].length).to eq 4
651
- end
650
+ it 'check 1 group' do
651
+ expect(@res[1].length).to eq 4
652
+ end
652
653
 
653
- it 'exist name' do
654
- expect(@res[1].key?('name')).to be_truthy
655
- expect(@res[1]['name']).to eq 'Ansible-Nginx'
656
- end
654
+ it 'exist name' do
655
+ expect(@res[1].key?('name')).to be_truthy
656
+ expect(@res[1]['name']).to eq 'Ansible-Nginx'
657
+ end
657
658
 
658
- it 'exist hosts' do
659
- expect(@res[1].key?('hosts')).to be_truthy
660
- expect(@res[1]['hosts']).to eq 'web'
661
- end
659
+ it 'exist hosts' do
660
+ expect(@res[1].key?('hosts')).to be_truthy
661
+ expect(@res[1]['hosts']).to eq 'web'
662
+ end
662
663
 
663
- it 'exist user' do
664
- expect(@res[1].key?('user')).to be_truthy
665
- expect(@res[1]['user']).to eq 'nginx'
666
- end
664
+ it 'exist user' do
665
+ expect(@res[1].key?('user')).to be_truthy
666
+ expect(@res[1]['user']).to eq 'nginx'
667
+ end
667
668
 
668
- it 'exist roles' do
669
- expect(@res[1].key?('roles')).to be_truthy
670
- expect(@res[1]['roles'].instance_of?(Array)).to be_truthy
671
- expect(@res[1]['roles'][0]).to eq 'nginx'
672
- end
669
+ it 'exist roles' do
670
+ expect(@res[1].key?('roles')).to be_truthy
671
+ expect(@res[1]['roles'].instance_of?(Array)).to be_truthy
672
+ expect(@res[1]['roles'][0]).to eq 'nginx'
673
+ end
673
674
 
674
- it 'exist name' do
675
- expect(@res[2].key?('name')).to be_truthy
676
- expect(@res[2]['name']).to eq 'Ansible-Nginx2'
677
- end
675
+ it 'exist name' do
676
+ expect(@res[2].key?('name')).to be_truthy
677
+ expect(@res[2]['name']).to eq 'Ansible-Nginx2'
678
+ end
678
679
 
679
- after do
680
- File.delete(tmp_pb)
681
- File.delete(tmp_inc)
680
+ after do
681
+ File.delete(tmp_pb)
682
+ File.delete(tmp_inc)
683
+ end
682
684
  end
683
685
  end
684
686
 
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.22
4
+ version: 0.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - volanja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-08 00:00:00.000000000 Z
11
+ date: 2018-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler