chef-provisioner 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef-provisioner.rb +1 -0
- data/lib/chef-provisioner/chef.rb +1 -1
- data/lib/chef-provisioner/config.rb +40 -0
- data/lib/chef-provisioner/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6b9b1e08ab9343bb6b63a0cd1a69d6387062af
|
4
|
+
data.tar.gz: 30287f0fd4e6557771518d2204835e4658d2e90c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364ca2a4e1bd74ec0dc50560a6ed1c753f2f873bbbf3b222bb5844304be15efed35656d9c552148b9cef910527d89bd888dd5d972f142b185a0e324cb348a3da
|
7
|
+
data.tar.gz: b6c64f37bbd4e172e784c96c26c0958acee207b8a767df9ee347d9229e37805470351125d3051b7b3d07af44cecfa449a57608f20422fa19d29acecab0633b16
|
data/lib/chef-provisioner.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
require 'chef-provisioner/chef'
|
5
|
+
|
6
|
+
module ChefProvisioner
|
7
|
+
module Config
|
8
|
+
extend self
|
9
|
+
|
10
|
+
attr_reader :server, :client_key, :client
|
11
|
+
|
12
|
+
def setup(server: nil, client_key: nil, client_key_path: nil, client: nil)
|
13
|
+
@server = server || "http://#{my_ip}:#{get_free_port}"
|
14
|
+
@client_key = client_key || client_key_path || setup_chef_client_file
|
15
|
+
@client = client || 'testing-client'
|
16
|
+
ChefProvisioner::Chef.configure(endpoint: @server, key_path: @client_key, client: @client)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def get_free_port
|
22
|
+
socket = Socket.new(:INET, :STREAM, 0)
|
23
|
+
socket.bind(Addrinfo.tcp("127.0.0.1", 0))
|
24
|
+
port = socket.local_address.ip_port
|
25
|
+
socket.close
|
26
|
+
port
|
27
|
+
end
|
28
|
+
|
29
|
+
def my_ip
|
30
|
+
Socket.ip_address_list.find{|x| x.ipv4? && !x.ipv4_loopback?}.ip_address
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup_chef_client_file
|
34
|
+
client_file = Tempfile.new('chef-provisioner-client')
|
35
|
+
client_file.write(OpenSSL::PKey::RSA.new(2048).to_s)
|
36
|
+
client_file.close
|
37
|
+
client_file.path
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Hamel
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/chef-provisioner.rb
|
90
90
|
- lib/chef-provisioner/bootstrap.rb
|
91
91
|
- lib/chef-provisioner/chef.rb
|
92
|
+
- lib/chef-provisioner/config.rb
|
92
93
|
- lib/chef-provisioner/templates/bootstrap.erb
|
93
94
|
- lib/chef-provisioner/version.rb
|
94
95
|
homepage: http://rubygems.org/gems/chef-zero-bootstrap
|