ansible_spec 0.0.1.2 → 0.0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +17 -2
- data/lib/ansible_spec.rb +39 -6
- data/lib/ansible_spec/version.rb +1 -1
- metadata +14 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3141f82d184b4f7dfaff006e07d4561aaa3ae7a
|
4
|
+
data.tar.gz: cb258abd59ebd2746d7d95e55464d1d308b267d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1cca18c66cb0becf5a8fd20de194527e807ec6e3bcd7031c4fadf9f41164f20ca92810c078b434e585362e3fb55621018177ea7fa8587f51eaa1c3c26780bf31
|
7
|
+
data.tar.gz: ae8b524a3b18033856f073c0fc25b3a1a72ff0de68953d3a2c7660f2f14c2897906720bc5f33565ad0a763b4626edbc4fda69cca2971ef11b4fa36dc8d9d79b4
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# AnsibleSpec
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/ansible_spec.svg)](http://badge.fury.io/rb/ansible_spec)
|
2
3
|
|
3
4
|
This is Severspec template for Run test Multi Role and Multi Host with Ansible
|
4
5
|
Create template (Rakefile and spec/spec_hepler.rb)
|
@@ -19,6 +20,19 @@ $ ansiblespec-init
|
|
19
20
|
create spec
|
20
21
|
create spec/spec_helper.rb
|
21
22
|
create Rakefile
|
23
|
+
create .ansiblespec
|
24
|
+
```
|
25
|
+
|
26
|
+
### Change .ansiblespec(v0.0.1.3)
|
27
|
+
If `.ansiblespec` is exist, use variables(playbook and inventory).
|
28
|
+
So, If you don't use `site.yml` and `hosts`, you change this file.
|
29
|
+
If `.ansiblespec` not found, use `site.yml` as playbook and `hosts` as inventory.
|
30
|
+
|
31
|
+
```.ansiblespec
|
32
|
+
---
|
33
|
+
-
|
34
|
+
playbook: site.yml
|
35
|
+
inventory: hosts
|
22
36
|
```
|
23
37
|
|
24
38
|
### Create Ansible Directory
|
@@ -27,9 +41,10 @@ sample is [here](https://github.com/volanja/ansible-sample-tdd)
|
|
27
41
|
|
28
42
|
```
|
29
43
|
.
|
44
|
+
├── .ansiblespec #Create file (use Serverspec). read [Change .ansiblespec(v0.0.1.3)](https://github.com/volanja/ansible_spec#change_ansiblespec_v0013)
|
30
45
|
├── README.md
|
31
|
-
├── hosts #use Ansible and Serverspec
|
32
|
-
├── site.yml #use Ansible and Serverspec
|
46
|
+
├── hosts #use Ansible and Serverspec if .ansiblespec is not exist.
|
47
|
+
├── site.yml #use Ansible and Serverspec if .ansiblespec is not exist.
|
33
48
|
├── nginx.yml #(comment-out) incluted by site.yml
|
34
49
|
├── roles
|
35
50
|
│ └── nginx
|
data/lib/ansible_spec.rb
CHANGED
@@ -11,6 +11,7 @@ module AnsibleSpec
|
|
11
11
|
def self.main()
|
12
12
|
safe_create_spec_helper
|
13
13
|
safe_create_rakefile
|
14
|
+
safe_create_ansiblespec
|
14
15
|
end
|
15
16
|
|
16
17
|
|
@@ -64,13 +65,30 @@ require 'rake'
|
|
64
65
|
require 'rspec/core/rake_task'
|
65
66
|
require 'yaml'
|
66
67
|
|
68
|
+
# param: none
|
69
|
+
# return: @playbook, @inventoryfile
|
70
|
+
def load_ansiblespec()
|
71
|
+
f = '.ansiblespec'
|
72
|
+
if File.exist?(f)
|
73
|
+
y = YAML.load_file(f)
|
74
|
+
@playbook = y[0]['playbook']
|
75
|
+
@inventoryfile = y[0]['inventory']
|
76
|
+
else
|
77
|
+
@playbook = 'site.yml'
|
78
|
+
@inventoryfile = 'hosts'
|
79
|
+
end
|
80
|
+
if File.exist?(@playbook) == false
|
81
|
+
puts 'Error: ' + @playbook + ' is not Found. create site.yml or /.ansiblespec See https://github.com/volanja/ansible_spec'
|
82
|
+
exit 1
|
83
|
+
elsif File.exist?(@inventoryfile) == false
|
84
|
+
puts 'Error: ' + @inventoryfile + ' is not Found. create hosts or /.ansiblespec See https://github.com/volanja/ansible_spec'
|
85
|
+
exit 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
67
89
|
# param: inventory file of Ansible
|
68
90
|
# return: Hash {"active_group_name" => ["192.168.0.1","192.168.0.2"]}
|
69
91
|
def load_host(file)
|
70
|
-
if File.exist?(file) == false
|
71
|
-
puts 'Error: Please create inventory file. name MUST "hosts"'
|
72
|
-
exit
|
73
|
-
end
|
74
92
|
hosts = File.open(file).read
|
75
93
|
active_group = Hash.new
|
76
94
|
active_group_name = ''
|
@@ -88,7 +106,9 @@ def load_host(file)
|
|
88
106
|
return active_group
|
89
107
|
end
|
90
108
|
|
91
|
-
|
109
|
+
# main
|
110
|
+
load_ansiblespec
|
111
|
+
load_file = YAML.load_file(@playbook)
|
92
112
|
|
93
113
|
# e.g. comment-out
|
94
114
|
if load_file === false
|
@@ -107,7 +127,7 @@ end
|
|
107
127
|
|
108
128
|
|
109
129
|
#load inventry file
|
110
|
-
hosts = load_host(
|
130
|
+
hosts = load_host(@inventoryfile)
|
111
131
|
properties.each do |var|
|
112
132
|
if hosts.has_key?("#{var["hosts"]}")
|
113
133
|
var["hosts"] = hosts["#{var["hosts"]}"]
|
@@ -137,6 +157,19 @@ EOF
|
|
137
157
|
|
138
158
|
end
|
139
159
|
|
160
|
+
def self.safe_create_ansiblespec
|
161
|
+
content = <<'EOF'
|
162
|
+
---
|
163
|
+
-
|
164
|
+
playbook: site.yml
|
165
|
+
inventory: hosts
|
166
|
+
EOF
|
167
|
+
safe_touch(".ansiblespec")
|
168
|
+
File.open(".ansiblespec", 'w') do |f|
|
169
|
+
f.puts content
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
140
173
|
def self.safe_mkdir(dir)
|
141
174
|
unless FileTest.exist?("#{dir}")
|
142
175
|
FileUtils.mkdir_p("#{dir}")
|
data/lib/ansible_spec/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansible_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- volanja
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-09-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,49 +27,43 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: serverspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 0.13.5
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.13.5
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: serverspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 0.13.5
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 0.13.5
|
78
69
|
description: This is Severspec template for Run test Multi Role and Multi Host with
|
@@ -96,26 +87,26 @@ files:
|
|
96
87
|
homepage: https://github.com/volanja
|
97
88
|
licenses:
|
98
89
|
- MIT
|
90
|
+
metadata: {}
|
99
91
|
post_install_message:
|
100
92
|
rdoc_options: []
|
101
93
|
require_paths:
|
102
94
|
- lib
|
103
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
96
|
requirements:
|
106
|
-
- -
|
97
|
+
- - '>='
|
107
98
|
- !ruby/object:Gem::Version
|
108
99
|
version: '0'
|
109
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
101
|
requirements:
|
112
|
-
- -
|
102
|
+
- - '>='
|
113
103
|
- !ruby/object:Gem::Version
|
114
104
|
version: '0'
|
115
105
|
requirements: []
|
116
106
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 2.1.11
|
118
108
|
signing_key:
|
119
|
-
specification_version:
|
109
|
+
specification_version: 4
|
120
110
|
summary: This is Severspec template for Run test Multi Role and Multi Host with Ansbile
|
121
111
|
test_files: []
|
112
|
+
has_rdoc:
|