Class: Soloist::RemoteConfig

Inherits:
Config
  • Object
show all
Defined in:
lib/soloist/remote_config.rb

Instance Attribute Summary collapse

Attributes inherited from Config

#royal_crown

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Config

#as_node_json, #as_solo_rb, #chef_solo, #compiled, #debug?, #log_level, #merge!

Constructor Details

#initialize(royal_crown, remote) ⇒ RemoteConfig

Returns a new instance of RemoteConfig.



13
14
15
16
# File 'lib/soloist/remote_config.rb', line 13

def initialize(royal_crown, remote)
  @royal_crown = royal_crown
  @remote = remote
end

Instance Attribute Details

#remoteObject (readonly)

Returns the value of attribute remote.



6
7
8
# File 'lib/soloist/remote_config.rb', line 6

def remote
  @remote
end

Class Method Details

.from_file(royal_crown_path, remote) ⇒ Object



8
9
10
11
# File 'lib/soloist/remote_config.rb', line 8

def self.from_file(royal_crown_path, remote)
  rc = Soloist::RoyalCrown.from_file(royal_crown_path)
  new(rc, remote)
end

Instance Method Details

#chef_cache_pathObject



34
35
36
37
38
# File 'lib/soloist/remote_config.rb', line 34

def chef_cache_path
  @chef_cache_path ||= "/var/chef/cache".tap do |cache_path|
    remote.system!(conditional_sudo("/bin/mkdir -m 777 -p #{cache_path}"))
  end
end

#chef_config_pathObject



40
41
42
43
44
# File 'lib/soloist/remote_config.rb', line 40

def chef_config_path
  @chef_config_path ||= "/etc/chef".tap do |path|
    remote.system!(conditional_sudo("/bin/mkdir -m 777 -p #{path}"))
  end
end

#cookbook_pathsObject



46
47
48
49
50
51
# File 'lib/soloist/remote_config.rb', line 46

def cookbook_paths
  @cookbook_paths ||= ["/var/chef/cookbooks".tap do |remote_path|
    remote.system!(conditional_sudo("/bin/mkdir -m 777 -p #{remote_path}"))
    super.each { |path| remote.upload("#{path}/", remote_path) }
  end]
end

#node_json_pathObject



22
23
24
25
26
# File 'lib/soloist/remote_config.rb', line 22

def node_json_path
  @node_json_path ||= File.expand_path("node.json", chef_config_path).tap do |path|
    remote.system!(%(echo '#{JSON.dump(as_node_json)}' | #{conditional_sudo("tee #{path}")}))
  end
end

#run_chefObject



18
19
20
# File 'lib/soloist/remote_config.rb', line 18

def run_chef
  remote.system!(conditional_sudo(%(/bin/bash -lc "#{chef_solo}")))
end

#solo_rb_pathObject



28
29
30
31
32
# File 'lib/soloist/remote_config.rb', line 28

def solo_rb_path
  @solo_rb_path ||= File.expand_path("solo.rb", chef_config_path).tap do |path|
    remote.system!(%(echo '#{as_solo_rb}' | #{conditional_sudo("tee #{path}")}))
  end
end