Added ruby manager. Partial

This commit is contained in:
Alexey Berezhok
2024-12-09 23:55:35 +03:00
parent d0da95dfc5
commit 4905975d79
9 changed files with 130 additions and 11 deletions

View File

@@ -9,6 +9,7 @@ class EmptyWorker < Kernel::ModuleCoreWorker
NAME: MODULE_ID,
DESCR: "Just empty module for storing max module id",
REQ: "",
CONF: "",
}
end

View File

@@ -15,6 +15,7 @@ class PassengerWorker < Kernel::ModuleCoreWorker
NAME: MODULE_ID,
DESCR: "Added passenger support for nginx",
REQ: "puppet_installer",
CONF: "yes",
}
end
@@ -28,6 +29,7 @@ class PassengerWorker < Kernel::ModuleCoreWorker
"Req error, needed #{inf[:REQ]}"
else
begin
prepare_default_ruby_conf
log("install packages for passenger + nginx support: /usr/bin/puppet apply --detailed-exitcodes #{f_inst_pp}")
result_action = `/usr/bin/puppet apply --detailed-exitcodes "#{f_inst_pp}"`
ex_status = $?.exitstatus
@@ -71,22 +73,73 @@ class PassengerWorker < Kernel::ModuleCoreWorker
end
end
def prepare_default_ruby_conf()
#TODO
def prepare_default_ruby_conf
ruby_conf_rubys = get_module_conf("rubys.conf")
return if File.exist?(ruby_conf_rubys)
arr = ["/usr/bin/ruby", "/opt/brepo/ruby33/bin/ruby"]
hestia_write_to_config_with_lock(ruby_conf_rubys, arr)
end
def return_rubys_from_conf
arr = []
ruby_conf_rubys = get_module_conf("rubys.conf")
return arr unless File.exist?(ruby_conf_rubys)
hestia_read_config_with_lock(ruby_conf_rubys)
end
def command(args)
if args.length < 1
log("Not enough arguments. Needed command")
"Not enough arguments. Needed command"
end
return log_return("Not enough arguments. Needed command") if args.length < 1
m_command = args[0].strip
case m_command
when "get_rubys"
#TODO
result = return_rubys_from_conf.map { |item| { "RUBY" => item } }
format = (args[1].nil? ? "shell" : args[1].strip)
hestia_print_array_of_hashes(result, format, "RUBY")
ACTION_OK
when "add_ruby"
path = args[1]
if path.nil?
log_return("Path to ruby should be specified. #{args}")
else
path = path.strip
if File.exist?(path)
rubys = return_rubys_from_conf
unless rubys.include? path
rubys << path
ruby_conf_rubys = get_module_conf("rubys.conf")
hestia_write_to_config_with_lock(ruby_conf_rubys, rubys)
end
ACTION_OK
else
log_return("File #{path} doesn't exists")
end
end
when "del_ruby"
path = args[1]
if path.nil?
log_return("Path to ruby should be specified. #{args}")
else
path = path.strip
rubys = return_rubys_from_conf
if rubys.include? path
rubys.delete(path)
ruby_conf_rubys = get_module_conf("rubys.conf")
hestia_write_to_config_with_lock(ruby_conf_rubys, rubys)
end
ACTION_OK
end
when "set_user_ruby"
domain = args[1]
if domain.nil?
log_return("Domain should be specified. #{args}")
else
#TODO
end
else
log("Unknown commands. #{args}")
"Unknown commands. #{args}"
log_return("Unknown commands. #{args}")
end
end

View File

@@ -12,6 +12,7 @@ class PuppetWorker < Kernel::ModuleCoreWorker
NAME: MODULE_ID,
DESCR: "Added puppet support, needed for another modules",
REQ: "",
CONF: "",
}
end