* Updated 'variables' -> 'variable_source_uuid' to type 'uuid' and removed the 'not null' constraint.
* Updated Database->insert_or_update_variables() to check/update 'variables_source_table' and 'variables_source_uuid'.
* Created the 'trusts' database table which will, when done, tell anvil-daemon which users@machines to trust (setup passwordkess SSH).
* Created (but not finished) System->manage_authorized_keys() and moved the logic over to it from anvil-daemon.
* Changed the host types "dashboard" to "striker".
* Moved the following methods from 'System' to 'Get';
** System->get_host_type to Get->host_type
** System->get_bridges to Get->bridges
** System->get_free_memory to Get->free_memory
** System->get_os_type to Get->os_type
** System->get_uptime to Get->uptime
* Updated striker to include the host_uuid for the 'node1', 'node2' and (if chosen) 'dr1' when running a job manifest.
Signed-off-by: Digimer <digimer@alteeve.ca>
Thisreturnsthelocalhost's system UUID (as reported by 'dmidecode'). If the host UUID isn'tavailable,andtheprogramisnotrunningwithrootpriviledges,C<<#!error!# >> is returned.
Thisreturnsthelocalhost's system UUID (as reported by 'dmidecode'). If the host UUID isn'tavailable,andtheprogramisnotrunningwithrootpriviledges,C<<#!error!# >> is returned.
B<<Note>>:Ifamachine's fingerprint changes, this method will NOT update C<< ~/.ssh/known_hosts >>! You will see an alert on the Striker dashboard prompting you to clear the bad keys (or, if that wasn'texpected,findthe"man in the middle"attacker).
-- Note that is all permissions are left false, the user can still interact with the Anvil! doing safe things, like changing optical media, perform migrations, start servers (but not stop them), etc.
-- Note that is all permissions are left false, the user can still interact with the Anvil! doing safe things, like changing optical media, perform migrations, start servers (but not stop them), etc.
CREATETABLEusers(
CREATETABLEusers(
user_uuiduuidnotnullprimarykey,-- This is the single most important record in Anvil!. Everything links back to here.
user_uuiduuidnotnullprimarykey,
user_nametextnotnull,
user_nametextnotnull,
user_password_hashtextnotnull,-- A user without a password is disabled.
user_password_hashtextnotnull,-- A user without a password is disabled.
user_salttextnotnull,-- This is used to enhance the security of the user's password.
user_salttextnotnull,-- This is used to enhance the security of the user's password.
@ -223,7 +223,7 @@ CREATE TRIGGER trigger_users
-- This stores special variables for a given host that programs may want to record.
-- This stores special variables for a given host that programs may want to record.
CREATETABLEhost_variable(
CREATETABLEhost_variable(
host_variable_uuiduuidnotnullprimarykey,-- This is the single most important record in ScanCore. Everything links back to here.
-- This stores user session information on a per-dashboard basis.
-- This stores user session information on a per-dashboard basis.
CREATETABLEsessions(
CREATETABLEsessions(
session_uuiduuidnotnullprimarykey,-- This is the single most important record in Anvil!. Everything links back to here.
session_uuiduuidnotnullprimarykey,
session_host_uuiduuidnotnull,-- This is the host uuid for this session.
session_host_uuiduuidnotnull,-- This is the host uuid for this session.
session_user_uuiduuidnotnull,-- This is the user uuid for the user logging in.
session_user_uuiduuidnotnull,-- This is the user uuid for the user logging in.
session_salttextnotnull,-- This is used when generating a session hash for a session when they log in.
session_salttextnotnull,-- This is used when generating a session hash for a session when they log in.
@ -642,7 +642,7 @@ CREATE TABLE variables (
variable_defaulttextnotnull,-- This acts as a reference for the user should they want to roll-back changes.
variable_defaulttextnotnull,-- This acts as a reference for the user should they want to roll-back changes.
variable_descriptiontextnotnull,-- This is a string key that describes this variable's use.
variable_descriptiontextnotnull,-- This is a string key that describes this variable's use.
variable_sectiontextnotnull,-- This is a free-form field that is used when displaying the various entries to a user. This allows for the various variables to be grouped into sections.
variable_sectiontextnotnull,-- This is a free-form field that is used when displaying the various entries to a user. This allows for the various variables to be grouped into sections.
variable_source_uuidtextnotnull,-- Optional; Marks the variable as belonging to a specific X_uuid, where 'X' is a table name set in 'variable_source_table'
variable_source_uuiduuid,-- Optional; Marks the variable as belonging to a specific X_uuid, where 'X' is a table name set in 'variable_source_table'
variable_source_tabletextnotnull,-- Optional; Marks the database table corresponding to the 'variable_source_uuid' value.
variable_source_tabletextnotnull,-- Optional; Marks the database table corresponding to the 'variable_source_uuid' value.
# Check that the users we care about have ssh public keys and they're recorded in ssh_keys.
# Check that the users we care about have ssh public keys and they're recorded in ssh_keys.
check_ssh_keys($anvil);
$anvil->System->check_ssh_keys({debug => 3});
# Check if the files on disk have changed. Even if it is time to check, don't if a job is
# Check if the files on disk have changed. Even if it is time to check, don't if a job is
# running.
# running.
@ -378,7 +382,7 @@ sub handle_periodic_tasks
}});
}});
# If we're a dashboard, see if the fence information needs to be gathered.
# If we're a dashboard, see if the fence information needs to be gathered.
if ($type eq "dashboard")
if ($type eq "striker")
{
{
# Even when this runs, it should finish in under ten seconds so we don't need to background it.
# Even when this runs, it should finish in under ten seconds so we don't need to background it.
my ($parse_output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{'striker-parse-fence-agents'}, source => $THIS_FILE, line => __LINE__});
my ($parse_output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{'striker-parse-fence-agents'}, source => $THIS_FILE, line => __LINE__});
@ -429,7 +433,7 @@ sub handle_periodic_tasks
### NOTE: We call it once/day, but this will also trigger on restart of anvil-daemon. As such, we
### NOTE: We call it once/day, but this will also trigger on restart of anvil-daemon. As such, we
### don't use '--force' and let striker-manage-install-target skip the repo update if it happened
### don't use '--force' and let striker-manage-install-target skip the repo update if it happened
### recently enough.
### recently enough.
if ($type eq "dashboard")
if ($type eq "striker")
{
{
# Record a job, don't call it directly. It takes too long to run.
# Record a job, don't call it directly. It takes too long to run.
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
my ($job_uuid) = $anvil->Database->insert_or_update_jobs({
@ -482,346 +486,6 @@ sub handle_periodic_tasks
return(0);
return(0);
}
}
# Check that the host's fingerprint and users we care about have ssh public keys and they're recorded in ssh_keys.
sub check_ssh_keys
{
my ($anvil) = @_;
### TODO: When a node is rebuilt, this causes the old keys to be reloaded between when we delete the entries. We need to delete the keys for the target IP from the 'ip_addresses' table.
return(0);
# Get a list of machine host keys and user public keys from other machines.
get_other_keys($anvil);
# Users to check:
# root, admin, hacluster
foreach my $user ("root", "admin")
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { user => $user }});
my $user_home = $anvil->Get->users_home({user => $user});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { user_home => $user_home }});
# If the user doesn't exist, their home directory won't either, so skip.
next if not $user_home;
next if not -d $user_home;
# If the user's ~/.ssh directory doesn't exist, we need to create it.