Class: Mimas::Server

Inherits:
Object
  • Object
show all
Includes:
SSH, Caddy, DeployUser, Harden, Ruby, Template, Terminal::Printer
Defined in:
lib/mimas/server.rb,
lib/mimas/server/ruby.rb,
lib/mimas/server/caddy.rb,
lib/mimas/server/harden.rb,
lib/mimas/server/console.rb,
lib/mimas/server/deploy_user.rb,
lib/mimas/server/prerequisites.rb

Defined Under Namespace

Modules: Caddy, Console, DeployUser, Harden, Prerequisites, Ruby

Constant Summary

Constants included from Template

Template::BASE_DIRECTORY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Harden

#harden

Methods included from DeployUser

#setup_deploy_user

Methods included from Ruby

#install_ruby, #install_ruby_prerequisites

Methods included from Caddy

#install_caddy

Methods included from SSH

#ssh

Methods included from Template

#copy_file, lookup_paths, #read_file, #template

Methods included from Terminal::Printer

#ask, #say

Constructor Details

#initialize(name, args) ⇒ Server

Returns a new instance of Server.



10
11
12
13
14
15
# File 'lib/mimas/server.rb', line 10

def initialize(name, args)
  @name = name
  @host = args[:host]
  @user = args[:user]
  @ssh_options = args.except(:host, :user)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/mimas/server.rb', line 8

def host
  @host
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/mimas/server.rb', line 8

def name
  @name
end

#ssh_optionsObject (readonly)

Returns the value of attribute ssh_options.



8
9
10
# File 'lib/mimas/server.rb', line 8

def ssh_options
  @ssh_options
end

#userObject (readonly)

Returns the value of attribute user.



8
9
10
# File 'lib/mimas/server.rb', line 8

def user
  @user
end

Instance Method Details

#current_path(site) ⇒ Object



33
34
35
# File 'lib/mimas/server.rb', line 33

def current_path(site)
  site_root(site).join("current")
end

#http_rootObject



21
22
23
# File 'lib/mimas/server.rb', line 21

def http_root
  @http_root ||= user_home.join("http")
end

#site_root(site) ⇒ Object



29
30
31
# File 'lib/mimas/server.rb', line 29

def site_root(site)
  http_root.join("#{site.domain}")
end

#user_homeObject



17
18
19
# File 'lib/mimas/server.rb', line 17

def user_home
  @user_home ||= Pathname.new(File.join("/", "home", @user.to_s))
end

#user_systemd_pathObject



25
26
27
# File 'lib/mimas/server.rb', line 25

def user_systemd_path
  @user_systemd_path ||= user_home.join(".config", "systemd", "user")
end

#validate!Object



37
38
39
40
41
42
43
44
45
# File 'lib/mimas/server.rb', line 37

def validate!
  raise Config::InvalidConfiguration.new("`server` requires a `host`") \
    unless self.host && self.host.size > 0

  raise Config::InvalidConfiguration.new("`server` requires a `user`") \
    unless self.user && self.user.size > 0

  true
end