Class: Natives::App

Inherits:
Object
  • Object
show all
Defined in:
lib/natives/app.rb

Instance Method Summary collapse

Instance Method Details

#create_solo_json_tempfile(catalog_name, packages, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/natives/app.rb', line 26

def create_solo_json_tempfile(catalog_name, packages, &block)
  file = Tempfile.new('natives.temp_attrs_file')
  file.write(json_attrs(catalog_name, packages))
  file.flush
  file.rewind
  begin
    block.call(file)
  ensure
    file.close!
  end
end

#install(catalog_name, packages) ⇒ Object



7
8
9
10
11
12
# File 'lib/natives/app.rb', line 7

def install(catalog_name, packages)
  create_solo_json_tempfile(catalog_name.to_s,
                            Array(packages)) do |attrs_file|
    run_chef_solo(attrs_file)
  end
end

#run_chef_solo(json_attrs_file) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/natives/app.rb', line 14

def run_chef_solo(json_attrs_file)
  ARGV.clear
  [
    '-c', File.join(gem_base_path, 'chef', 'solo.rb'),
    '-o', 'natives',
    '-j', json_attrs_file.to_path
  ].each do |token|
    ARGV << token
  end
  Chef::Application::Solo.new.run
end