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 +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +4 -0
- data/README.md +8 -1
- data/lib/ansible_spec/load_ansible.rb +4 -0
- data/lib/ansible_spec/version.rb +1 -1
- data/lib/src/spec/spec_helper.rb +9 -8
- data/spec/load_ansible_spec.rb +74 -72
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea92ad1db5c6331ab0f51cb0cc9f8357d6fad5a1
|
4
|
+
data.tar.gz: 3529e094be9910fb8acb9c1e3df7661e4e21135e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f8121627c3ffb1b2011e8b77d2ef0704b8f64ab59075c2973e7768c7fb26a1c21606332acdb7a6faedc1d4d17be4287abf354de010fc4c72ded2d7db003aa88
|
7
|
+
data.tar.gz: ded735c540319da5a2443d9639390f3e0a5d915a5249e410d0295f3f32b99b09bcc6625384d2778784bf8f7484f4f199a6a5c52b6dce9eb2f0a6149927f59d3b
|
data/.travis.yml
CHANGED
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
|
data/lib/ansible_spec/version.rb
CHANGED
data/lib/src/spec/spec_helper.rb
CHANGED
@@ -34,15 +34,16 @@ when 'ssh'
|
|
34
34
|
set :become_password, ENV['BECOME_PASSWORD']
|
35
35
|
end
|
36
36
|
|
37
|
-
|
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]
|
44
|
-
options[:port]
|
45
|
-
options[:keys]
|
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
|
data/spec/load_ansible_spec.rb
CHANGED
@@ -570,22 +570,23 @@ EOF
|
|
570
570
|
end
|
571
571
|
end
|
572
572
|
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
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
|
-
-
|
585
|
+
- #{action}: nginx.yml
|
585
586
|
EOF
|
586
|
-
|
587
|
+
create_file(tmp_pb,content_pb)
|
587
588
|
|
588
|
-
|
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
|
-
|
602
|
+
create_file(tmp_inc,content_inc)
|
602
603
|
|
603
|
-
|
604
|
-
|
604
|
+
@res = AnsibleSpec.load_playbook(tmp_pb)
|
605
|
+
end
|
605
606
|
|
606
|
-
|
607
|
-
|
608
|
-
|
607
|
+
it 'res is array' do
|
608
|
+
expect(@res.instance_of?(Array)).to be_truthy
|
609
|
+
end
|
609
610
|
|
610
|
-
|
611
|
-
|
612
|
-
|
611
|
+
it 'res has three groups' do
|
612
|
+
expect(@res.length).to eq 3
|
613
|
+
end
|
613
614
|
|
614
615
|
|
615
|
-
|
616
|
-
|
617
|
-
|
616
|
+
it 'res is hash' do
|
617
|
+
expect(@res[0].instance_of?(Hash)).to be_truthy
|
618
|
+
end
|
618
619
|
|
619
|
-
|
620
|
-
|
621
|
-
|
620
|
+
it 'check 1 group' do
|
621
|
+
expect(@res[0].length).to eq 4
|
622
|
+
end
|
622
623
|
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
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
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
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
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
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
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
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
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
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
|
-
|
650
|
-
|
651
|
-
|
650
|
+
it 'check 1 group' do
|
651
|
+
expect(@res[1].length).to eq 4
|
652
|
+
end
|
652
653
|
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
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
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
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
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
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
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
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
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
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
|
-
|
680
|
-
|
681
|
-
|
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.
|
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-
|
11
|
+
date: 2018-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|