Module: ChefApply::TargetHost::Linux

Defined in:
lib/chef_apply/target_host/linux.rb

Constant Summary collapse

MKTEMP_COMMAND =
"d=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); echo $d".freeze

Instance Method Summary collapse

Instance Method Details

#chown(path, owner) ⇒ Object



17
18
19
20
21
# File 'lib/chef_apply/target_host/linux.rb', line 17

def chown(path, owner)
  owner ||= user
  run_command!("chown #{owner} '#{path}'")
  nil
end

#del_dir(path) ⇒ Object



46
47
48
# File 'lib/chef_apply/target_host/linux.rb', line 46

def del_dir(path)
  del_file(path)
end

#del_file(path) ⇒ Object



42
43
44
# File 'lib/chef_apply/target_host/linux.rb', line 42

def del_file(path)
  run_command!("rm -rf #{path}")
end

#install_package(target_package_path) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/chef_apply/target_host/linux.rb', line 31

def install_package(target_package_path)
  install_cmd = case File.extname(target_package_path)
                when ".rpm"
                  "rpm -Uvh #{target_package_path}"
                when ".deb"
                  "dpkg -i #{target_package_path}"
                end
  run_command!(install_cmd)
  nil
end

#make_temp_dirObject



23
24
25
26
27
28
29
# File 'lib/chef_apply/target_host/linux.rb', line 23

def make_temp_dir
  # We will cache this so that we only
  @tempdir ||= begin
    res = run_command!("bash -c '#{MKTEMP_COMMAND}'")
    res.stdout.chomp.strip
  end
end

#mkdir(path) ⇒ Object



13
14
15
# File 'lib/chef_apply/target_host/linux.rb', line 13

def mkdir(path)
  run_command!("mkdir -p #{path}")
end

#normalize_path(path) ⇒ Object

Nothing to escape in a linux-based path



55
56
57
# File 'lib/chef_apply/target_host/linux.rb', line 55

def normalize_path(path)
  path
end

#omnibus_manifest_pathObject



6
7
8
9
10
11
# File 'lib/chef_apply/target_host/linux.rb', line 6

def omnibus_manifest_path
  # TODO - if habitat install on target, this won't work
  # Note that we can't use File::Join, because that will render for the
  # CURRENT platform - not the platform of the target.
  "/opt/chef/version-manifest.json"
end

#ws_cache_pathObject



50
51
52
# File 'lib/chef_apply/target_host/linux.rb', line 50

def ws_cache_path
  "/var/chef-workstation"
end