ansible_spec 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/ansible_spec.gemspec +1 -0
- data/lib/ansible_spec/load_ansible.rb +2 -0
- data/lib/ansible_spec/version.rb +1 -1
- data/lib/src/Rakefile +2 -0
- data/lib/src/spec/spec_helper.rb +68 -28
- data/spec/ssh_spec.rb +8 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b872942bcb5a26a23247723d84188a992f97a60
|
4
|
+
data.tar.gz: 21638a57a71751bddee6bffbe849f9f8fbe39ee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47625ffe1bf1c4e0f81c22908c2b904215b7681a719f95559fab61e522524d28be309cec5bd77a21a3a4f28fa872e1036df637ae417ccb4e36947f9b7022285c
|
7
|
+
data.tar.gz: 05078e9080269b7f7dc9d793dde918e4a1af5c1839b3905fcdde229c4c74f707e2980ff650dcfebb8baf787214231d5e1d6818166ac93a8bec22a0934344a2b9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
- v0.2.11
|
2
|
+
- Merge [Support Windows](https://github.com/volanja/ansible_spec/pull/68) by [takuyakawabuchi](https://github.com/takuyakawabuchi)
|
3
|
+
|
1
4
|
# v0.2.10
|
2
5
|
- Merge [support group and host variables without yml extention.](https://github.com/volanja/ansible_spec/pull/66) by [okamototk](https://github.com/okamototk)
|
3
6
|
|
data/ansible_spec.gemspec
CHANGED
@@ -148,6 +148,8 @@ module AnsibleSpec
|
|
148
148
|
host['private_key'] = value if key == "ansible_ssh_private_key_file"
|
149
149
|
host['user'] = value if key == "ansible_ssh_user"
|
150
150
|
host['uri'] = value if key == "ansible_ssh_host"
|
151
|
+
host['pass'] = value if key == "ansible_ssh_pass"
|
152
|
+
host['connection'] = value if key == "ansible_connection"
|
151
153
|
end
|
152
154
|
}
|
153
155
|
return host
|
data/lib/ansible_spec/version.rb
CHANGED
data/lib/src/Rakefile
CHANGED
data/lib/src/spec/spec_helper.rb
CHANGED
@@ -1,46 +1,86 @@
|
|
1
1
|
require 'serverspec'
|
2
2
|
require 'net/ssh'
|
3
3
|
require 'ansible_spec'
|
4
|
+
require 'winrm'
|
4
5
|
|
5
|
-
|
6
|
+
#
|
7
|
+
# Set ansible variables to serverspec property
|
8
|
+
#
|
9
|
+
host = ENV['TARGET_HOST']
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
rescue LoadError
|
11
|
-
fail "highline is not available. Try installing it."
|
12
|
-
end
|
13
|
-
set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
|
14
|
-
else
|
15
|
-
set :sudo_password, ENV['SUDO_PASSWORD']
|
16
|
-
end
|
11
|
+
group_idx = ENV['TARGET_GROUP_INDEX'].to_i
|
12
|
+
vars = AnsibleSpec.get_variables(host, group_idx)
|
13
|
+
set_property vars
|
17
14
|
|
18
|
-
|
15
|
+
connection = ENV['TARGET_CONNECTION']
|
16
|
+
|
17
|
+
if connection != 'winrm'
|
18
|
+
#
|
19
|
+
# OS type: UN*X
|
20
|
+
#
|
21
|
+
set :backend, :ssh
|
19
22
|
|
20
|
-
|
23
|
+
if ENV['ASK_SUDO_PASSWORD']
|
24
|
+
begin
|
25
|
+
require 'highline/import'
|
26
|
+
rescue LoadError
|
27
|
+
fail "highline is not available. Try installing it."
|
28
|
+
end
|
29
|
+
set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
|
30
|
+
else
|
31
|
+
set :sudo_password, ENV['SUDO_PASSWORD']
|
32
|
+
end
|
21
33
|
|
22
|
-
options
|
23
|
-
options[:port] ||= ENV['TARGET_PORT']
|
24
|
-
options[:keys] ||= ENV['TARGET_PRIVATE_KEY']
|
34
|
+
options = Net::SSH::Config.for(host)
|
25
35
|
|
26
|
-
|
27
|
-
|
36
|
+
options[:user] ||= ENV['TARGET_USER']
|
37
|
+
options[:port] ||= ENV['TARGET_PORT']
|
38
|
+
options[:keys] ||= ENV['TARGET_PRIVATE_KEY']
|
28
39
|
|
29
|
-
|
30
|
-
|
40
|
+
set :host, options[:host_name] || host
|
41
|
+
set :ssh_options, options
|
31
42
|
|
43
|
+
# Disable sudo
|
44
|
+
# set :disable_sudo, true
|
32
45
|
|
33
|
-
# Set environment variables
|
34
|
-
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
|
35
46
|
|
36
|
-
# Set
|
37
|
-
# set :
|
47
|
+
# Set environment variables
|
48
|
+
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
|
38
49
|
|
50
|
+
# Set PATH
|
51
|
+
# set :path, '/sbin:/usr/local/sbin:$PATH'
|
52
|
+
else
|
39
53
|
#
|
40
|
-
#
|
54
|
+
# OS type: Windows
|
41
55
|
#
|
56
|
+
set :backend, :winrm
|
57
|
+
set :os, :family => 'windows'
|
42
58
|
|
43
|
-
|
59
|
+
user = ENV['TARGET_USER']
|
60
|
+
port = ENV['TARGET_PORT']
|
61
|
+
pass = ENV['TARGET_PASSWORD']
|
44
62
|
|
45
|
-
|
46
|
-
|
63
|
+
if user.nil?
|
64
|
+
begin
|
65
|
+
require 'highline/import'
|
66
|
+
rescue LoadError
|
67
|
+
fail "highline is not available. Try installing it."
|
68
|
+
end
|
69
|
+
user = ask("\nEnter #{host}'s login user: ") { |q| q.echo = true }
|
70
|
+
end
|
71
|
+
if pass.nil?
|
72
|
+
begin
|
73
|
+
require 'highline/import'
|
74
|
+
rescue LoadError
|
75
|
+
fail "highline is not available. Try installing it."
|
76
|
+
end
|
77
|
+
pass = ask("\nEnter #{user}@#{host}'s login password: ") { |q| q.echo = false }
|
78
|
+
end
|
79
|
+
|
80
|
+
endpoint = "http://#{host}:#{port}/wsman"
|
81
|
+
|
82
|
+
winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
|
83
|
+
winrm.set_timeout 300 # 5 minutes max timeout for any operation
|
84
|
+
Specinfra.configuration.winrm = winrm
|
85
|
+
|
86
|
+
end
|
data/spec/ssh_spec.rb
CHANGED
@@ -84,6 +84,13 @@ describe 'ssh' do
|
|
84
84
|
expect(v.host).to eq 'db-b.example.com'
|
85
85
|
end
|
86
86
|
|
87
|
+
it '192.168.1.3 ansible_connection=winrm ansible_ssh_port=5985 ansible_ssh_user=administrator ansible_ssh_pass=Passw0rd' do
|
88
|
+
v = @h["task_10"]
|
89
|
+
expect(v.host).to eq '192.168.1.3'
|
90
|
+
expect(v.user).to eq 'administrator'
|
91
|
+
expect(v.port).to eq '5985'
|
92
|
+
end
|
93
|
+
|
87
94
|
after do
|
88
95
|
delete_normality
|
89
96
|
end
|
@@ -170,6 +177,7 @@ EOF
|
|
170
177
|
jumper ansible_ssh_port=5555 ansible_ssh_host=192.168.1.50
|
171
178
|
www[01:02].example.com
|
172
179
|
db-[a:b].example.com
|
180
|
+
192.168.1.3 ansible_connection=winrm ansible_ssh_port=5985 ansible_ssh_user=administrator ansible_ssh_pass=Passw0rd
|
173
181
|
EOF
|
174
182
|
|
175
183
|
File.open(tmp_ansiblespec, 'w') do |f|
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- volanja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03
|
11
|
+
date: 2016-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: winrm
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Ansible Config Parser for Serverspec. Run test Multi Role and Multi Host
|
112
126
|
by Ansible Configuration
|
113
127
|
email:
|