Class: Confer::Configurators::Tzdata

Inherits:
Confer::Configurator show all
Defined in:
lib/confer/configurators/tzdata.rb

Overview

Public: Configures the timezone on the remote host.

Attributes

timezone - The desired time zone in the format expected by the file

`/etc/timezone` on a Linux machine.  E.g. London, UK would
be `Europe/London`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Confer::Configurator

get, #initialize

Constructor Details

This class inherits a constructor from Confer::Configurator

Instance Attribute Details

#timezoneObject

Public: The desired time zone.



20
21
22
# File 'lib/confer/configurators/tzdata.rb', line 20

def timezone
  @timezone
end

Instance Method Details

#apply(connection) ⇒ Object

See ‘Confer::Configurator#apply`



41
42
43
44
# File 'lib/confer/configurators/tzdata.rb', line 41

def apply(connection)
  # sh "echo '#{params[:timezone]}' > /etc/timezone"
  # sh "dpkg-reconfigure -f noninteractive tzdata"
end

#query(connection) ⇒ Object

See ‘Confer::Configurator#query`



25
26
27
# File 'lib/confer/configurators/tzdata.rb', line 25

def query(connection)
  connection.exec! 'cat /etc/timezone'
end

#verify(connection) ⇒ Object

See ‘Confer::Configurator#verify`



32
33
34
35
36
# File 'lib/confer/configurators/tzdata.rb', line 32

def verify(connection)
  expected = query.strip
  return true if expected == timezone
  Diffy::Diff.new(expected, timezone).to_s(:color)
end