Class: Spaux::Chef::Client

Inherits:
Chef::Application::Client
  • Object
show all
Defined in:
lib/spaux/chef/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work_dir, *args) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/spaux/chef/client.rb', line 10

def initialize(work_dir, *args)
  @work_dir = work_dir
  chef_config = args.shift  || {}
  spaux_config = args.shift || {}
  super()

  default_chef_config = Spaux::default_chef_config(:client)

  default_chef_config.each { |_,v| v.is_a?(String) && v.gsub!(/@work_dir/, @work_dir) }
  @config.merge! default_chef_config.merge(chef_config)

  default_spaux_config = Spaux::default_spaux_config

  @spaux_config = default_spaux_config.merge(spaux_config)
  #if !@spaux_config.eql?(default_spaux_config)
    #trigger a reevalutation of the private key

  @config[:raw_key] = Spaux::Chef::RawKey

  FileUtils.touch @config[:config_file]
  FileUtils.touch @config[:client_key]
  unless chef_config[:json_attribs]
    @config.delete(:json_attribs) if !::File.exists?(@config[:json_attribs])
  end
  ENV['SPAUX_HOME'] = @work_dir
end

Instance Attribute Details

#spaux_configObject

Returns the value of attribute spaux_config.



8
9
10
# File 'lib/spaux/chef/client.rb', line 8

def spaux_config
  @spaux_config
end

#work_dirObject

Returns the value of attribute work_dir.



7
8
9
# File 'lib/spaux/chef/client.rb', line 7

def work_dir
  @work_dir
end

Instance Method Details

#parse_options(argv = ARGV) ⇒ Object



42
43
44
45
# File 'lib/spaux/chef/client.rb', line 42

def parse_options(argv=ARGV)
  argv = []
  super
end

#reconfigureObject



37
38
39
40
# File 'lib/spaux/chef/client.rb', line 37

def reconfigure
  super
  ::Chef::Config[:specific_recipes] = []
end

#run_applicationObject



47
48
49
50
51
52
53
# File 'lib/spaux/chef/client.rb', line 47

def run_application
  begin
    super
  rescue SystemExit => e
    # just ignore chef-client exit
  end
end