Class: ConfigCurator::ConfigFile

Inherits:
Unit
  • Object
show all
Defined in:
lib/config_curator/units/config_file.rb

Overview

A config file is a file that should be copied.

Constant Summary

Constants inherited from Unit

Unit::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from Unit

#hosts, #logger, #packages

Instance Method Summary collapse

Methods inherited from Unit

#allowed_host?, #destination_path, #initialize, #options, #package_lookup, #packages_installed?, #source_path, #uninstall?

Constructor Details

This class inherits a constructor from ConfigCurator::Unit

Instance Attribute Details

#fmodeObject

Returns the value of attribute fmode.


4
5
6
# File 'lib/config_curator/units/config_file.rb', line 4

def fmode
  @fmode
end

#groupObject

Returns the value of attribute group.


4
5
6
# File 'lib/config_curator/units/config_file.rb', line 4

def group
  @group
end

#ownerObject

Returns the value of attribute owner.


4
5
6
# File 'lib/config_curator/units/config_file.rb', line 4

def owner
  @owner
end

Instance Method Details

#destinationObject

Note:

Use Unit#source by default.

Returns the value of attribute destination.


21
22
23
24
# File 'lib/config_curator/units/config_file.rb', line 21

def destination
  super
  @destination ||= @source
end

#installBoolean

Installs the unit.

Returns:

  • (Boolean)

    if the unit was installed


35
36
37
38
39
40
41
42
# File 'lib/config_curator/units/config_file.rb', line 35

def install
  s = super
  return s unless s
  install_file
  set_mode
  set_owner
  true
end

#install?Boolean

Checks if the unit should be installed.

Returns:

  • (Boolean)

    if the unit should be installed


45
46
47
48
49
50
51
# File 'lib/config_curator/units/config_file.rb', line 45

def install?
  s = super
  return s unless s
  fail InstallFailed, 'No file source path specified.' if source_path.nil?
  fail InstallFailed, "Source path does not exist: #{source}" unless File.exist? source_path
  true
end

#sourceObject

Will use files of the form filename.hostname.ext if found. (see Unit#source)


8
9
10
11
12
13
14
15
16
17
# File 'lib/config_curator/units/config_file.rb', line 8

def source
  path = super
  host_specific_file = search_for_host_specific_file path if path

  if host_specific_file
    return host_specific_file
  else
    return path
  end
end

#uninstall(*args) ⇒ Boolean

Uninstalls the unit.

Returns:

  • (Boolean)

    if the unit was uninstalled


27
28
29
30
31
32
# File 'lib/config_curator/units/config_file.rb', line 27

def uninstall(*args)
  s = super(*args)
  return s unless s
  uninstall_file
  true
end