From 42ffc200bc172a1e5e9743f76cd5a3482e3c2e69 Mon Sep 17 00:00:00 2001 From: Digimer Date: Mon, 24 May 2021 14:34:15 -0400 Subject: [PATCH] * Updated remainder pointers to the old repos to the new repos. Added support for the new alteeve-repo-setup. * Removed the checks for resync that limited resyncs on jobs and variables tables. That approach to minimize unnecessary resyncshas proven faulty, will find another way later. Signed-off-by: Digimer --- Anvil/Tools.pm | 5 +-- Anvil/Tools/Database.pm | 7 ----- html/skins/alteeve/pxe.txt | 2 +- tools/striker-auto-initialize-all | 2 +- tools/striker-initialize-host | 49 +++++++++++++++++++++++++++-- tools/striker-manage-install-target | 38 +++++++--------------- 6 files changed, 63 insertions(+), 40 deletions(-) diff --git a/Anvil/Tools.pm b/Anvil/Tools.pm index 5ff1056e..42b6191e 100644 --- a/Anvil/Tools.pm +++ b/Anvil/Tools.pm @@ -1017,7 +1017,7 @@ sub _set_paths # Executables $anvil->data->{path} = { configs => { - 'alteeve-el8.repo' => "/etc/yum.repos.d/alteeve-el8.repo", + 'alteeve-release.repo' => "/etc/yum.repos.d/alteeve-release.repo", 'anvil.conf' => "/etc/anvil/anvil.conf", 'anvil.version' => "/etc/anvil/anvil.version", 'autoindex.conf' => "/etc/httpd/conf.d/autoindex.conf", @@ -1090,7 +1090,7 @@ sub _set_paths units => "/usr/lib/systemd/system", }, exe => { - ocf_alteeve => "/usr/lib/ocf/resource.d/alteeve/server", + 'alteeve-repo-setup' => "/usr/sbin/alteeve-repo-setup", 'anvil-boot-server' => "/usr/sbin/anvil-boot-server", 'anvil-change-password' => "/usr/sbin/anvil-change-password", 'anvil-check-memory' => "/usr/sbin/anvil-check-memory", @@ -1179,6 +1179,7 @@ sub _set_paths mv => "/usr/bin/mv", nmap => "/usr/bin/nmap", nmcli => "/bin/nmcli", + ocf_alteeve => "/usr/lib/ocf/resource.d/alteeve/server", openssl => "/usr/bin/openssl", 'osinfo-query' => "/usr/bin/osinfo-query", passwd => "/usr/bin/passwd", diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 454b2b99..e30e8733 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -16116,13 +16116,6 @@ ORDER BY "s3:sys::database::table::${table}::uuid::${uuid}::row_count" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count}, }}); - if ((($table eq "jobs") or ($table eq "variables")) && ($difference < 10)) - { - # These often fall out of sync and trigger resyncs when in fact it - # was just a change that happened between counting columns. - next; - } - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0219", variables => { missing => $difference, table => $table, diff --git a/html/skins/alteeve/pxe.txt b/html/skins/alteeve/pxe.txt index 2291e184..cdc0566b 100644 --- a/html/skins/alteeve/pxe.txt +++ b/html/skins/alteeve/pxe.txt @@ -82,7 +82,7 @@ selinux --permissive %packages @^minimal-environment -#alteeve-el8-repo +#alteeve-release #createrepo #dhcp-server #firefox diff --git a/tools/striker-auto-initialize-all b/tools/striker-auto-initialize-all index 09bcb9d3..e5149c22 100755 --- a/tools/striker-auto-initialize-all +++ b/tools/striker-auto-initialize-all @@ -326,6 +326,7 @@ sub configure_machine_networks } my ($job_uuid) = $anvil->Database->insert_or_update_jobs({ + debug => 2, job_host_uuid => $machine_host_uuid, job_command => $anvil->data->{path}{exe}{'anvil-configure-host'}.$anvil->Log->switches, job_data => "form::config_step2", @@ -334,7 +335,6 @@ sub configure_machine_networks job_description => "job_0071", job_progress => 0, }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { job_uuid => $job_uuid }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0266", variables => { host_name => $host_name, job_uuid => $job_uuid, diff --git a/tools/striker-initialize-host b/tools/striker-initialize-host index 4a719d1e..e2eda4a7 100755 --- a/tools/striker-initialize-host +++ b/tools/striker-initialize-host @@ -59,6 +59,7 @@ set_host_name($anvil); add_repos($anvil); configure_lvm($anvil); add_databases($anvil); +$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0047"}); update_progress($anvil, 100, "job_0047"); $anvil->nice_exit({exit_code => 0}); @@ -371,9 +372,31 @@ sub add_repos update_progress($anvil, $anvil->data->{job}{progress}, "job_0028"); # Add the local repo. - my $repo = $anvil->Striker->get_local_repo({debug => 3}); + my $repo = $anvil->Striker->get_local_repo({debug => 2}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { repo => $repo }}); + # If this striker is an enterprise user, get the key for when we initialize targets. + my $enterprise_key = ""; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "path::configs::alteeve-release.repo" => $anvil->data->{path}{configs}{'alteeve-release.repo'}, + }}); + if (-e $anvil->data->{path}{configs}{'alteeve-release.repo'}) + { + # Read the file + my $alteeve_repo = $anvil->Storage->read_file({file => $anvil->data->{path}{configs}{'alteeve-release.repo'}}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { alteeve_repo => $alteeve_repo }}); + foreach my $line (split/\n/, $alteeve_repo) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }}); + if ($line =~ /baseurl=.*?\/enterprise\/.*?\/(.*?)\//) + { + $enterprise_key = $1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { enterprise_key => $enterprise_key }}); + last; + } + } + } + if ($repo) { # NOTE: We can't use Storage->write_file() because the target may not have 'rsync' installed @@ -612,7 +635,6 @@ EOF # If this is a CentOS Stream OS, enable the HA repo. my ($os_type, $os_arch) = $anvil->Get->os_type({ - debug => 2, password => $anvil->data->{data}{password}, port => $anvil->data->{data}{ssh_port}, target => $anvil->data->{data}{host_ip_address}, @@ -728,7 +750,7 @@ EOF $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }}); next if $line =~ /anvil-core/; - if ($line =~ /alteeve.*repo.noarch/) + if ($line =~ /alteeve-release.noarch/) { $alteeve_repo = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { alteeve_repo => $alteeve_repo }}); @@ -785,6 +807,27 @@ EOF error => $error, return_code => $return_code, }}); + + # If successful, we now need to configure the repo. + $shell_call = $anvil->data->{path}{exe}{'alteeve-repo-setup'}." --yes"; + if ($enterprise_key) + { + $shell_call = $anvil->data->{path}{exe}{'alteeve-repo-setup'}." --key ".$enterprise_key." --yes"; + } + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + ($output, $error, $return_code) = $anvil->Remote->call({ + debug => 2, + shell_call => $shell_call, + password => $anvil->data->{data}{password}, + port => $anvil->data->{data}{ssh_port}, + target => $anvil->data->{data}{host_ip_address}, + remote_user => "root", + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + output => $output, + error => $error, + return_code => $return_code, + }}); } } } diff --git a/tools/striker-manage-install-target b/tools/striker-manage-install-target index f1359796..a9f1c8af 100755 --- a/tools/striker-manage-install-target +++ b/tools/striker-manage-install-target @@ -939,36 +939,22 @@ sub check_alteeve_repo { my ($anvil) = @_; - my $repo_url = ""; - my $repo_file = ""; - ### NOTE: This adds 'b' for the beta repo - if (1) - { - ### TODO: Remove this and the check when the signed el8 repo is ready - $repo_file = "/etc/yum.repos.d/alteeve-el".$anvil->data->{host_os}{version}.".repo"; - $repo_url = "https://alteeve.com/an-repo/el".$anvil->data->{host_os}{version}."b/alteeve-el".$anvil->data->{host_os}{version}."b-repo-latest.noarch.rpm"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { - repo_file => $repo_file, - repo_url => $repo_url, - }}); - } - else - { - ### TODO: Update this when rhel8 is out - $repo_file = "/etc/yum.repos.d/alteeve-el".$anvil->data->{host_os}{version}."b.repo"; - $repo_url = "https://alteeve.com/an-repo/el".$anvil->data->{host_os}{version}."/alteeve-el".$anvil->data->{host_os}{version}."-repo-latest.noarch.rpm"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { - repo_file => $repo_file, - repo_url => $repo_url, - }}); - } + my $repo_file = "/etc/yum.repos.d/alteeve-anvil.repo"; + my $repo_url = "https://www.alteeve.com/an-repo/m3/anvil-release-latest.noarch.rpm"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { + repo_file => $repo_file, + repo_url => $repo_url, + }}); # If the repo file doesn't exist, try to install it. if (not -e $repo_file) { # Install the repo - my ($handle, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{rpm}." -Uvh ".$repo_url }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { handle => $handle, return_code => $return_code }}); + my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{dnf}." -y install ".$repo_url }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + output => $output, + return_code => $return_code, + }}); } # If it still doesn't exist, we're done. @@ -1489,7 +1475,7 @@ sub load_packages "adwaita-gtk2-theme.x86_64", "adwaita-icon-theme.noarch", "alsa-lib.x86_64", - "alteeve-el8-repo.noarch", + "alteeve-release.noarch", "annobin.x86_64", "anvil-core.noarch", "anvil-dr.noarch",