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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d34726ed0b909efc94a80fcf64b341c654760659
4
- data.tar.gz: 2a16de554e8f5342ba85ea520f13eb5677603de5
3
+ metadata.gz: df6b9b1e08ab9343bb6b63a0cd1a69d6387062af
4
+ data.tar.gz: 30287f0fd4e6557771518d2204835e4658d2e90c
5
5
  SHA512:
6
- metadata.gz: 9f7a878f9bc249d271da890f6d7770e3c2877c8c0186a68e2d850514e3705f1c7ad6f6bdb9e25e7827991a7252d78e0507414d598867c19727f31695d6c4f6ae
7
- data.tar.gz: e1566cb4e81214035d8027bacc9c601d688a523fbfc86fc469fa04a762eab380abed539655d6d67d81de50002e1d059a4d41e71bb39cb3b08130e32847223d0a
6
+ metadata.gz: 364ca2a4e1bd74ec0dc50560a6ed1c753f2f873bbbf3b222bb5844304be15efed35656d9c552148b9cef910527d89bd888dd5d972f142b185a0e324cb348a3da
7
+ data.tar.gz: b6c64f37bbd4e172e784c96c26c0958acee207b8a767df9ee347d9229e37805470351125d3051b7b3d07af44cecfa449a57608f20422fa19d29acecab0633b16
@@ -3,3 +3,4 @@ $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
3
3
  require 'chef-provisioner/version'
4
4
  require 'chef-provisioner/chef'
5
5
  require 'chef-provisioner/bootstrap'
6
+ require 'chef-provisioner/config'
@@ -12,7 +12,7 @@ module ChefProvisioner
12
12
  ChefAPI.configure do |config|
13
13
  config.endpoint = kwargs[:endpoint]
14
14
  config.client = kwargs[:client]
15
- config.key = kwargs[:key_path]
15
+ config.key = kwargs[:key_text] || File.read(kwargs[:key_path])
16
16
  end
17
17
  end
18
18
 
@@ -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
@@ -1,4 +1,4 @@
1
1
  # Namespace for our gem
2
2
  module ChefProvisioner
3
- VERSION = '0.0.8'
3
+ VERSION = '0.0.9'
4
4
  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.8
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