Class: Mimas::Server

Inherits:
Object
  • Object
show all
Includes:
SSH, Caddy, Console, 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 Console

#start_console

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.



12
13
14
15
16
17
# File 'lib/mimas/server.rb', line 12

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.



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

def host
  @host
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#ssh_optionsObject (readonly)

Returns the value of attribute ssh_options.



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

def ssh_options
  @ssh_options
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#current_path(site) ⇒ Object



35
36
37
# File 'lib/mimas/server.rb', line 35

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

#http_rootObject



23
24
25
# File 'lib/mimas/server.rb', line 23

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

#site_root(site) ⇒ Object



31
32
33
# File 'lib/mimas/server.rb', line 31

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

#user_homeObject



19
20
21
# File 'lib/mimas/server.rb', line 19

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

#user_systemd_pathObject



27
28
29
# File 'lib/mimas/server.rb', line 27

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

#validate!Object



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

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