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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39b483b0e6e4712c41e9785d82a8a7f04c0bdaea
4
- data.tar.gz: c4f559f6ffa278fc2c50f553fff48af455cd6431
3
+ metadata.gz: 3b872942bcb5a26a23247723d84188a992f97a60
4
+ data.tar.gz: 21638a57a71751bddee6bffbe849f9f8fbe39ee3
5
5
  SHA512:
6
- metadata.gz: d4d2724571d72783076e2ce0f27cdd4f9516720015cb2977f796353e92ac7aae9e93e40e62c7a2e6929c456a1b284e1544e1d088ffd642161df6dcbbfa3ef499
7
- data.tar.gz: 0807543a869a4bfe97ef9ed716f223840975c419f76d964dda4eacc88d4d533061b97b614bf44f1d51b2f24a1184c40ffe4535c83cb6917d4480a06f36932e0b
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
@@ -26,5 +26,6 @@ Gem::Specification.new do |gem|
26
26
  gem.add_runtime_dependency "serverspec", ">= 2.0.0"
27
27
  gem.add_runtime_dependency "hostlist_expression"
28
28
  gem.add_runtime_dependency "oj"
29
+ gem.add_runtime_dependency "winrm"
29
30
 
30
31
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module AnsibleSpec
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.11"
3
3
  end
data/lib/src/Rakefile CHANGED
@@ -22,6 +22,8 @@ namespace :serverspec do
22
22
  else
23
23
  ENV['TARGET_USER'] = property["user"]
24
24
  end
25
+ ENV['TARGET_PASSWORD'] = host["pass"]
26
+ ENV['TARGET_CONNECTION'] = host["connection"]
25
27
 
26
28
  roles = property["roles"]
27
29
  for role in property["roles"]
@@ -1,46 +1,86 @@
1
1
  require 'serverspec'
2
2
  require 'net/ssh'
3
3
  require 'ansible_spec'
4
+ require 'winrm'
4
5
 
5
- set :backend, :ssh
6
+ #
7
+ # Set ansible variables to serverspec property
8
+ #
9
+ host = ENV['TARGET_HOST']
6
10
 
7
- if ENV['ASK_SUDO_PASSWORD']
8
- begin
9
- require 'highline/import'
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
- host = ENV['TARGET_HOST']
15
+ connection = ENV['TARGET_CONNECTION']
16
+
17
+ if connection != 'winrm'
18
+ #
19
+ # OS type: UN*X
20
+ #
21
+ set :backend, :ssh
19
22
 
20
- options = Net::SSH::Config.for(host)
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[:user] ||= ENV['TARGET_USER']
23
- options[:port] ||= ENV['TARGET_PORT']
24
- options[:keys] ||= ENV['TARGET_PRIVATE_KEY']
34
+ options = Net::SSH::Config.for(host)
25
35
 
26
- set :host, options[:host_name] || host
27
- set :ssh_options, options
36
+ options[:user] ||= ENV['TARGET_USER']
37
+ options[:port] ||= ENV['TARGET_PORT']
38
+ options[:keys] ||= ENV['TARGET_PRIVATE_KEY']
28
39
 
29
- # Disable sudo
30
- # set :disable_sudo, true
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 PATH
37
- # set :path, '/sbin:/usr/local/sbin:$PATH'
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
- # Set ansible variables to serverspec property
54
+ # OS type: Windows
41
55
  #
56
+ set :backend, :winrm
57
+ set :os, :family => 'windows'
42
58
 
43
- group_idx = ENV['TARGET_GROUP_INDEX'].to_i
59
+ user = ENV['TARGET_USER']
60
+ port = ENV['TARGET_PORT']
61
+ pass = ENV['TARGET_PASSWORD']
44
62
 
45
- vars = AnsibleSpec.get_variables(host, group_idx)
46
- set_property vars
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.10
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-13 00:00:00.000000000 Z
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: