spaux 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ca6cdb0701d57bb9e1e6757409f445751a7be00
4
- data.tar.gz: ebc351a25943fb1ac5a927d6ef349404dd9eb3cf
3
+ metadata.gz: 98ef4d4b5b2c48f5bc4eb185a96c9ae636653482
4
+ data.tar.gz: cfd56cada6b0dc2cc3f082add195dfe014c7380a
5
5
  SHA512:
6
- metadata.gz: 49a94afda451ae1327d989492ccf24f26e8b7edd2798f2f6e97b13332b0688f02f260ac4089f8678a705866a22597871237a761312cbd7045b2b924a1de12b86
7
- data.tar.gz: c01509c2736bd400bb0c878f967b67468ebac7995ca09f3419232bfa0f1c4b335c2eb0dba58d2cea3da37dc156e2250e01782e3815513441f5fe16526f053c68
6
+ metadata.gz: 312b7fdb2479fdd59c6de22b2aab1ebe1b1aec0aae5edfd3bf7066ddfe54b9d1eea7317981d6e0804e1e8a0d70029ea96993288fec0d9caa40f74786d24c9a4d
7
+ data.tar.gz: bb268b6677d3403d947ae482efaa6d345b42b05b18dc7fa5d2a28e4159eaf6966e1501c75aeafba67b2ca6ba4b3b0ce05d2ccba6056b2fb25b84143042f8e918
@@ -1,5 +1,5 @@
1
1
  require 'spaux/chef/key'
2
- require 'spaux/chef/monkey_patches'
2
+ require 'spaux/chef/monkey_patches/client'
3
3
 
4
4
  class Spaux
5
5
  class Chef
@@ -7,27 +7,19 @@ class Spaux
7
7
  attr_accessor :work_dir
8
8
  attr_accessor :spaux_config
9
9
 
10
- DEFAULT_CHEF_CONFIG = {
11
- config_file: ::File.join('@work_dir', 'client.rb'),
12
- cache_path: ::File.join('@work_dir', '.chef'),
13
- client_key: ::File.join('@work_dir', 'client.pem'),
14
- json_attribs: ::File.join('@work_dir', 'attributes.json'),
15
- chef_server_url: 'https://api.opscode.com/organizations/spaux',
16
- ssl_verify_mode: :verify_peer,
17
- node_name: 'spaux',
18
- override_runlist: ["recipe[spaux::machine]"]
19
- }
20
-
21
10
  def initialize(work_dir, *args)
22
11
  @work_dir = work_dir
23
12
  chef_config = args.shift || {}
24
13
  spaux_config = args.shift || {}
25
14
  super()
26
15
 
27
- DEFAULT_CHEF_CONFIG.each { |_,v| v.is_a?(String) && v.gsub!(/@work_dir/, @work_dir) }
28
- @config.merge! DEFAULT_CHEF_CONFIG.merge(chef_config)
16
+ default_chef_config = Spaux::default_chef_config(:client)
17
+
18
+ default_chef_config.each { |_,v| v.is_a?(String) && v.gsub!(/@work_dir/, @work_dir) }
19
+ @config.merge! default_chef_config.merge(chef_config)
20
+
21
+ default_spaux_config = Spaux::default_spaux_config
29
22
 
30
- default_spaux_config = Spaux::Chef::Key::DEFAULT_SPAUX_CONFIG
31
23
  @spaux_config = default_spaux_config.merge(spaux_config)
32
24
  #if !@spaux_config.eql?(default_spaux_config)
33
25
  #trigger a reevalutation of the private key
@@ -0,0 +1,8 @@
1
+ config_file ::File.join('@work_dir', 'client.rb')
2
+ cache_path ::File.join('@work_dir', '.chef')
3
+ client_key ::File.join('@work_dir', 'client.pem')
4
+ json_attribs ::File.join('@work_dir', 'attributes.json')
5
+ chef_server_url 'https://api.opscode.com/organizations/spaux'
6
+ ssl_verify_mode :verify_peer
7
+ node_name 'spaux'
8
+ override_runlist ["recipe[spaux::machine]"]
File without changes
@@ -8,20 +8,19 @@ class Spaux
8
8
  attr_accessor :raw_key
9
9
  attr_accessor :config
10
10
 
11
- DEFAULT_SPAUX_CONFIG = {
12
- chef_private_key_gist_id: '16b65a73953427ce9c40',
13
- private_key: '~/.ssh/id_rsa',
14
- aes_key_size: 256,
15
- aes_cipher_mode: :CBC
16
- }
17
-
18
11
  def initialize(config={})
19
12
  @work_dir = ::File.join(ENV['PWD'], 'current')
20
- @config = config.merge(DEFAULT_SPAUX_CONFIG)
13
+ @config = config.merge(default_spaux_config)
21
14
  @raw_key ||= get_raw_key
22
15
  end
23
16
 
24
17
  private
18
+ # this is wrong, this should in Spaux class
19
+ def default_spaux_config
20
+ spaux_dir = ::File.expand_path(::File::join(__FILE__, '..', '..'))
21
+ config_file = ::File.join(spaux_dir, 'config.rb')
22
+ configuration = eval(::File.read(config_file))
23
+ end
25
24
  def get_raw_key
26
25
  key_filename = 'encrypted.rb'
27
26
  key_file = ::File.join(@work_dir, key_filename)
@@ -1,6 +1,6 @@
1
1
  require 'chef/application/knife'
2
2
  require 'fileutils'
3
- require 'spaux/chef/knife_monkey_patches'
3
+ require 'spaux/chef/monkey_patches/knife'
4
4
 
5
5
  class Spaux
6
6
  class Chef
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  class Knife
3
3
  def configure_spaux
4
- config.merge!(Spaux::default_knife_config)
4
+ config.merge!(Spaux::default_chef_config(:knife))
5
5
  end
6
6
  def self.run(args, options={})
7
7
  # Fallback debug logging. Normally the logger isn't configured until we
data/lib/spaux/cli.rb CHANGED
@@ -10,16 +10,7 @@ class Spaux
10
10
  option :current, :type => :boolean, :default => true,
11
11
  :desc => 'Create and/or use a working directory in the current directory'
12
12
  def converge
13
- work_dir = options[:dir]
14
- if not work_dir
15
- if ENV['SPAUX_HOME']
16
- work_dir = ENV['SPAUX_HOME']
17
- elsif options[:current]
18
- work_dir = ::File.join(ENV['PWD'], 'current')
19
- else
20
- work_dir = Dir.mktmpdir
21
- end
22
- end
13
+ work_dir = get_work_dir(options)
23
14
  FileUtils.mkdir_p work_dir
24
15
 
25
16
  client = Spaux::Chef::Client.new(work_dir)
@@ -0,0 +1,6 @@
1
+ {
2
+ chef_private_key_gist_id: '16b65a73953427ce9c40',
3
+ private_key: '~/.ssh/id_rsa',
4
+ aes_key_size: 256,
5
+ aes_cipher_mode: :CBC
6
+ }
data/lib/spaux/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Spaux
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/lib/spaux.rb CHANGED
@@ -4,10 +4,34 @@ require 'spaux/chef/client'
4
4
  require 'spaux/chef/knife'
5
5
 
6
6
  class Spaux
7
- def self.default_knife_config
7
+ def self.default_config_dir(component)
8
8
  lib_dir = ::File.expand_path(::File::join(__FILE__, '..'))
9
- knife_rb = ::File::join(lib_dir, 'spaux', 'defaults', 'knife.rb')
10
- ::Chef::Config.from_string(::File.read(knife_rb), knife_rb)
9
+ dir = case component
10
+ when :chef
11
+ chef_conf_dir = ::File::join(lib_dir, 'spaux', 'chef', 'default')
12
+ when :spaux
13
+ spaux_conf_dir = ::File::join(lib_dir, 'spaux')
14
+ end
15
+ end
16
+
17
+ def self.default_chef_config(component)
18
+ filename = case component
19
+ when :client
20
+ 'client.rb'
21
+ when :knife
22
+ 'knife.rb'
23
+ else
24
+ raise 'Unknown component'
25
+ end
26
+
27
+ config_file = ::File.join(default_config_dir(:chef), filename)
28
+ ::Chef::Config.from_string(::File.read(config_file), config_file)
11
29
  ::Chef::Config.configuration
12
30
  end
31
+
32
+ def self.default_spaux_config
33
+ config_dir = default_config_dir(:spaux)
34
+ config_file = ::File.join(config_dir, 'config.rb')
35
+ configuration = eval(::File.read(config_file))
36
+ end
13
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spaux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Landaeta
@@ -183,12 +183,14 @@ files:
183
183
  - examples/knife_minimal.rb
184
184
  - lib/spaux.rb
185
185
  - lib/spaux/chef/client.rb
186
+ - lib/spaux/chef/default/client.rb
187
+ - lib/spaux/chef/default/knife.rb
186
188
  - lib/spaux/chef/key.rb
187
189
  - lib/spaux/chef/knife.rb
188
- - lib/spaux/chef/knife_monkey_patches.rb
189
- - lib/spaux/chef/monkey_patches.rb
190
+ - lib/spaux/chef/monkey_patches/client.rb
191
+ - lib/spaux/chef/monkey_patches/knife.rb
190
192
  - lib/spaux/cli.rb
191
- - lib/spaux/defaults/knife.rb
193
+ - lib/spaux/config.rb
192
194
  - lib/spaux/version.rb
193
195
  - spaux.gemspec
194
196
  - spec/spaux_spec.rb