class Bakist::RemoteConfig
Attributes
remote[R]
Public Class Methods
from_file(royal_crown_path, remote)
click to toggle source
# File lib/bakist/remote_config.rb, line 8 def self.from_file(royal_crown_path, remote) rc = Bakist::RoyalCrown.from_file(royal_crown_path) new(rc, remote) end
new(royal_crown, remote)
click to toggle source
# File lib/bakist/remote_config.rb, line 13 def initialize(royal_crown, remote) @royal_crown = royal_crown @remote = remote end
Public Instance Methods
chef_cache_path()
click to toggle source
# File lib/bakist/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_path()
click to toggle source
# File lib/bakist/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_paths()
click to toggle source
Calls superclass method
Bakist::Config#cookbook_paths
# File lib/bakist/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_path()
click to toggle source
# File lib/bakist/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_chef()
click to toggle source
# File lib/bakist/remote_config.rb, line 18 def run_chef remote.system!(conditional_sudo(%(/bin/bash -lc "#{chef_solo}"))) end
solo_rb_path()
click to toggle source
# File lib/bakist/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
Protected Instance Methods
conditional_sudo(command)
click to toggle source
# File lib/bakist/remote_config.rb, line 54 def conditional_sudo(command) root? ? command : "/usr/bin/sudo -E #{command}" end
root?()
click to toggle source
# File lib/bakist/remote_config.rb, line 58 def root? remote.user == "root" end