* Fixed a bug in Striker->load_manifest() where fences were parsed twice, the second time missing a hash reference.

* Updated striker to now only offer gateway for IFN networks. EL8 seems to ignore 'GATEWAY="x"' in interface configs which caused anvil-join-anvil to always think an interface needs to be updated. Updated as well to remove DNS entries set in interfaces that are not the default gateway.
* Fixed a bug where DNS entries were being missed, causing entries to be repeatedly added to the interface that was the gateway interface.
* In anvil-update-states, added Get->switches() so that verbosity switches are used.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 1bf71f8428
commit d2d5d7b460
  1. 9
      Anvil/Tools/Striker.pm
  2. 12
      Anvil/Tools/System.pm
  3. 52
      cgi-bin/striker
  4. 1
      rpm/SPECS/anvil.spec
  5. 10
      share/words.xml
  6. 283
      tools/anvil-join-anvil
  7. 7
      tools/anvil-update-states
  8. 5
      tools/test.pl

@ -920,15 +920,6 @@ WHERE
}}); }});
} }
foreach my $hash_ref (@{$parsed_xml->{fences}{fence}})
{
my $fence_name = $hash_ref->{name};
$anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{fences}{$fence_name} = $hash_ref->{uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"manifests::manifest_uuid::${manifest_uuid}::parsed::fences::${fence_name}" => $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{fences}{$fence_name},
}});
}
$anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{dns} = $parsed_xml->{networks}{dns}; $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{dns} = $parsed_xml->{networks}{dns};
$anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{ntp} = $parsed_xml->{networks}{ntp}; $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{ntp} = $parsed_xml->{networks}{ntp};
$anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{mtu} = $parsed_xml->{networks}{mtu}; $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}{networks}{mtu} = $parsed_xml->{networks}{mtu};

@ -641,7 +641,7 @@ This method does several things;
1. This makes sure the users on this system have SSH keys, and creates the keys if needed. 1. This makes sure the users on this system have SSH keys, and creates the keys if needed.
2. It records the user's keys in the C<< ssh_keys >> table. 2. It records the user's keys in the C<< ssh_keys >> table.
3. For the dashboard machines it uses, it adds their host machine public key (SSH fingerprint) to C<< ~/.ssh/known_hosts >>. 3. For the dashboard machines whose databases this host uses, it adds their host machine public key (SSH fingerprint) to C<< ~/.ssh/known_hosts >>.
4. If this machine is a node or DR host, it sets up passwordless SSH between the other machines in the same Anvil! system. 4. If this machine is a node or DR host, it sets up passwordless SSH between the other machines in the same Anvil! system.
This works on the C<< admin >> and C<< root >> users. If the host is a node, it will also work on the c<< hacluster >> user. This works on the C<< admin >> and C<< root >> users. If the host is a node, it will also work on the c<< hacluster >> user.
@ -660,16 +660,16 @@ sub check_ssh_keys
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_memory()" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_memory()" }});
# We do a couple things here. First we make sure our user's keys are up to date and stored in the # We do a couple things here. First we make sure our user's keys are up to date and stored in the
# 'ssh_keys' table. Then we look through the 'trusts' table for any other users@hosts we're supposed # 'ssh_keys' table. Then we look through the 'Get->trusted_hosts' array any other users@hosts we're
# to trust. For each, we make sure that they're in the appropriate local user's authorized_keys file. # supposed to trust. For each, we make sure that they're in the appropriate local user's
my $users = $anvil->Get->host_type eq "node" ? ["root", "admin", "hacluster"] : ["root", "admin"]; # authorized_keys file.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { users => \@{$users} }});
# Load the host keys and the SSH keys # Load the host keys and the SSH keys
$anvil->Database->get_hosts({debug => $debug}); $anvil->Database->get_hosts({debug => $debug});
$anvil->Database->get_ssh_keys({debug => $debug}); $anvil->Database->get_ssh_keys({debug => $debug});
# Users to check: # Users to check:
my $users = ["root", "admin"];
foreach my $user (@{$users}) foreach my $user (@{$users})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { user => $user }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { user => $user }});
@ -3967,7 +3967,7 @@ sub update_hosts
# Get the list of hosts we trust. # Get the list of hosts we trust.
my $trusted_host_uuids = $anvil->Get->trusted_hosts({debug => $debug}); my $trusted_host_uuids = $anvil->Get->trusted_hosts({debug => $debug});
$anvil->Database->get_ip_addresses({debug => 2}); $anvil->Database->get_ip_addresses({debug => $debug});
foreach my $host_uuid (keys %{$anvil->data->{hosts}{host_uuid}}) foreach my $host_uuid (keys %{$anvil->data->{hosts}{host_uuid}})
{ {

@ -1694,6 +1694,53 @@ sub run_manifest
dr1_anvil => $dr1_anvil, dr1_anvil => $dr1_anvil,
}}); }});
# Make sure the three options are unique.
if ($node1_host_uuid eq $node2_host_uuid)
{
my $message = $anvil->Words->string({key => "warning_0054"});
$problem = 1;
$anvil->data->{cgi}{node1_host}{alert} = 1;
$anvil->data->{cgi}{node2_host}{alert} = 1;
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
problem => $problem,
"cgi::node1_host::alert" => $anvil->data->{cgi}{node1_host}{alert},
"cgi::node2_host::alert" => $anvil->data->{cgi}{node2_host}{alert},
"form::error_massage" => $anvil->data->{form}{error_massage},
}});
}
if ($dr1_host_uuid)
{
if ($dr1_host_uuid eq $node1_host_uuid)
{
my $message = $anvil->Words->string({key => "warning_0055"});
$problem = 1;
$anvil->data->{cgi}{dr1_host}{alert} = 1;
$anvil->data->{cgi}{node1_host}{alert} = 1;
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
problem => $problem,
"cgi::dr1_host::alert" => $anvil->data->{cgi}{dr1_host}{alert},
"cgi::node1_host::alert" => $anvil->data->{cgi}{node1_host}{alert},
"form::error_massage" => $anvil->data->{form}{error_massage},
}});
}
elsif ($dr1_host_uuid eq $node2_host_uuid)
{
my $message = $anvil->Words->string({key => "warning_0056"});
$problem = 1;
$anvil->data->{cgi}{dr1_host}{alert} = 1;
$anvil->data->{cgi}{node2_host}{alert} = 1;
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $message }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
problem => $problem,
"cgi::dr1_host::alert" => $anvil->data->{cgi}{dr1_host}{alert},
"cgi::node2_host::alert" => $anvil->data->{cgi}{node2_host}{alert},
"form::error_massage" => $anvil->data->{form}{error_massage},
}});
}
}
if (($node1_anvil) && ($node1_anvil ne $anvil_name)) if (($node1_anvil) && ($node1_anvil ne $anvil_name))
{ {
# The server belongs to another Anvil! system. # The server belongs to another Anvil! system.
@ -2540,15 +2587,12 @@ sub handle_manifest
"cgi::${gateway_key}::alert" => $anvil->data->{cgi}{$gateway_key}{alert}, "cgi::${gateway_key}::alert" => $anvil->data->{cgi}{$gateway_key}{alert},
}}); }});
$network_form .= $anvil->Template->get({file => "anvil.html", name => "manifest-step2-network-entry-gateway", variables => { $network_form .= $anvil->Template->get({file => "anvil.html", name => "manifest-step2-network-entry", variables => {
network => $say_bcn, network => $say_bcn,
network_name => $network_key, network_name => $network_key,
network_class => $anvil->data->{cgi}{$network_key}{alert} ? "input_alert" : "", network_class => $anvil->data->{cgi}{$network_key}{alert} ? "input_alert" : "",
network_value => $anvil->data->{cgi}{$network_key}{value}, network_value => $anvil->data->{cgi}{$network_key}{value},
subnet => '255.255.0.0 <input type="hidden" name="'.$subnet_key.'" id="'.$subnet_key.'" value="'.$anvil->data->{cgi}{$subnet_key}{value}.'" />', subnet => '255.255.0.0 <input type="hidden" name="'.$subnet_key.'" id="'.$subnet_key.'" value="'.$anvil->data->{cgi}{$subnet_key}{value}.'" />',
gateway_name => $gateway_key,
gateway_class => $anvil->data->{cgi}{$gateway_key}{alert} ? "input_alert" : "",
gateway_value => $anvil->data->{cgi}{$gateway_key}{value},
}}); }});
} }

@ -24,6 +24,7 @@ WARNING: This is an alpha-stage project. Many features are missing and this
%package core %package core
Summary: Alteeve's Anvil! Core package Summary: Alteeve's Anvil! Core package
Requires: bash-completion Requires: bash-completion
Requires: binutils
Requires: chrony Requires: chrony
Requires: bind-utils Requires: bind-utils
Requires: dmidecode Requires: dmidecode

@ -341,7 +341,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<key name="job_0094">Enabled and started the daemon: [#!variable!daemon!#].</key> <key name="job_0094">Enabled and started the daemon: [#!variable!daemon!#].</key>
<key name="job_0095">Disable and stop the daemon: [#!variable!daemon!#].</key> <key name="job_0095">Disable and stop the daemon: [#!variable!daemon!#].</key>
<key name="job_0096">This is a DR host, skipping pacemaker configuration.</key> <key name="job_0096">This is a DR host, skipping pacemaker configuration.</key>
<key name="job_0097"><![CDATA[[ Error ] - Authorizing against 'pcsd' failed. Will try again in a moment in case we're waiting for the peer node to set its 'hacluster' shell user password.]]></key> <key name="job_0097"><![CDATA[[ Error ] - Authorizing against 'pcsd' failed. Has the peer configured it's 'hacluster' user yet?. Will try again in a moment.]]></key>
<key name="job_0098">Successfully authorized using 'pcsd' on both nodes.</key> <key name="job_0098">Successfully authorized using 'pcsd' on both nodes.</key>
<key name="job_0099">No existing cluster found, will run initial setup.</key> <key name="job_0099">No existing cluster found, will run initial setup.</key>
<key name="job_0100">The corosync.conf file does not exist locally, but it does exist on the peer. Copying the file to here.</key> <key name="job_0100">The corosync.conf file does not exist locally, but it does exist on the peer. Copying the file to here.</key>
@ -354,6 +354,11 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<key name="job_0107">Corosync is not yet configured, waiting. It will be created when node 1 initializes the cluster.</key> <key name="job_0107">Corosync is not yet configured, waiting. It will be created when node 1 initializes the cluster.</key>
<key name="job_0108">Corosync is configured. Will wait for the cluster to start. If it hasn't started in two minutes, we'll try to join it.</key> <key name="job_0108">Corosync is configured. Will wait for the cluster to start. If it hasn't started in two minutes, we'll try to join it.</key>
<key name="job_0109">We will now wait for the cluster to start.</key> <key name="job_0109">We will now wait for the cluster to start.</key>
<key name="job_0110">The interface: [#!variable!interface!#] has a DNS entry: [#!variable!dns_line!#], but it is not the default gateway. Removing the line.</key>
<key name="job_0111">The interface: [#!variable!interface!#] has a GATEWAY entry: [#!variable!gateway_line!#], but it is not the default gateway. Removing the line.</key>
<key name="job_0112">Updating the '/etc/hosts' file.</key>
<key name="job_0113">Checking the SSH configuration.</key>
<key name="job_0114">Configuring the IPMI BMC. Please be patient, this could take a minute.</key>
<!-- Log entries --> <!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key> <key name="log_0001">Starting: [#!variable!program!#].</key>
@ -1715,6 +1720,9 @@ The error was:
#!variable!error!# #!variable!error!#
======== ========
</key> </key>
<key name="warning_0054">[ Warning ] - Node 1 and Node 2 are set to the same machine.</key>
<key name="warning_0055">[ Warning ] - The DR Host is set to the same machine as Node 1.</key>
<key name="warning_0056">[ Warning ] - The DR Host is set to the same machine as Node 2.</key>
</language> </language>
<!-- 日本語 --> <!-- 日本語 -->

@ -258,6 +258,7 @@ sub configure_pacemaker
{ {
# Try to authenticate against the peer. # Try to authenticate against the peer.
my $auth_shell_call = $anvil->data->{path}{exe}{pcs}." host auth ".$node1_host_name." ".$node2_host_name." -u hacluster -p ".$escaped_password; my $auth_shell_call = $anvil->data->{path}{exe}{pcs}." host auth ".$node1_host_name." ".$node2_host_name." -u hacluster -p ".$escaped_password;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { auth_shell_call => $auth_shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => 3, secure => 1, shell_call => $auth_shell_call}); my ($output, $return_code) = $anvil->System->call({debug => 3, secure => 1, shell_call => $auth_shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output, output => $output,
@ -369,171 +370,9 @@ sub configure_pacemaker
} }
} }
# Setup fencing!
die;
=cut =cut
$anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed}; $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}{parsed};
$VAR1 = {
'fences' => {
'pulsar' => 'c2be8d2e-045e-45d0-80e7-7443f2314fb1',
'el8-pdu02' => '2681049b-1ae7-444a-890b-39aca262e79e',
'el8-pdu01' => 'bad1fc5c-5342-4385-8d0d-a87a342dd87d',
'an-nas02' => '4117a862-f58f-4676-991a-9ca257a3c612'
},
'domain' => 'digimer.ca',
'networks' => {
'count' => {
'ifn' => 1,
'bcn' => 1,
'sn' => 1
},
'dns' => '8.8.8.8,8.8.4.4',
'mtu' => '1500',
'ntp' => '10.201.14.1,10.201.14.2',
'name' => {
'ifn1' => {
'subnet' => '255.255.255.0',
'gateway' => '192.168.122.1',
'network' => '192.168.122.0'
},
'bcn1' => {
'network' => '10.201.0.0',
'gateway' => '',
'subnet' => '255.255.0.0'
},
'sn1' => {
'gateway' => '',
'network' => '10.101.0.0',
'subnet' => '255.255.0.0'
}
}
},
'upses' => {
'el8-ups01' => {
'uuid' => '7ebecdda-782d-4624-841d-98d912ed3d50'
},
'el8-ups02' => {
'uuid' => '7ffb4dc2-8b96-4ca7-80bb-49e309fb2f5f'
}
},
'machine' => {
'node2' => {
'network' => {
'bcn1' => {
'ip' => '10.201.10.2'
},
'sn1' => {
'ip' => '10.101.10.2'
},
'ifn1' => {
'ip' => '192.168.122.12'
}
},
'ups' => {
'el8-ups01' => {
'used' => '0'
},
'el8-ups02' => {
'used' => '0'
}
},
'fence' => {
'pulsar' => {
'port' => ''
},
'el8-pdu02' => {
'port' => ''
},
'el8-pdu01' => {
'port' => ''
},
'an-nas02' => {
'port' => 'el8-a01n02'
}
},
'name' => 'el8-a01n02',
'ipmi_ip' => ''
},
'node1' => {
'ipmi_ip' => '',
'name' => 'el8-a01n01',
'ups' => {
'el8-ups02' => {
'used' => '0'
},
'el8-ups01' => {
'used' => '0'
}
},
'network' => {
'ifn1' => {
'ip' => '192.168.122.11'
},
'bcn1' => {
'ip' => '10.201.10.1'
},
'sn1' => {
'ip' => '10.101.10.1'
}
},
'fence' => {
'el8-pdu02' => {
'port' => ''
},
'pulsar' => {
'port' => ''
},
'an-nas02' => {
'port' => 'el8-a01n01'
},
'el8-pdu01' => {
'port' => ''
}
}
},
'dr1' => {
'fence' => {
'pulsar' => {
'port' => ''
},
'el8-pdu02' => {
'port' => ''
},
'el8-pdu01' => {
'port' => ''
},
'an-nas02' => {
'port' => ''
}
},
'network' => {
'bcn1' => {
'ip' => '10.201.10.3'
},
'sn1' => {
'ip' => '10.101.10.3'
},
'ifn1' => {
'ip' => '192.168.122.13'
}
},
'ups' => {
'el8-ups02' => {
'used' => '0'
},
'el8-ups01' => {
'used' => '0'
}
},
'name' => 'el8-a01dr01',
'ipmi_ip' => ''
}
},
'sequence' => '01',
'name' => 'el8-anvil-01',
'prefix' => 'el8'
};
909; xxx::upses::el8-ups01::uuid: [7ebecdda-782d-4624-841d-98d912ed3d50] 909; xxx::upses::el8-ups01::uuid: [7ebecdda-782d-4624-841d-98d912ed3d50]
909; xxx::upses::el8-ups02::uuid: [7ffb4dc2-8b96-4ca7-80bb-49e309fb2f5f] 909; xxx::upses::el8-ups02::uuid: [7ffb4dc2-8b96-4ca7-80bb-49e309fb2f5f]
@ -679,7 +518,6 @@ sub check_local_network
}}); }});
foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}})
{ {
### BUG: DNS gets replicated, but updated.
# Only one interface will start with the network name and have an IP address. # Only one interface will start with the network name and have an IP address.
next if $in_iface !~ /^${network}_/; next if $in_iface !~ /^${network}_/;
next if not $anvil->data->{network}{'local'}{interface}{$in_iface}{ip}; next if not $anvil->data->{network}{'local'}{interface}{$in_iface}{ip};
@ -709,6 +547,7 @@ sub check_local_network
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { default_gateway_interface => $default_gateway_interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { default_gateway_interface => $default_gateway_interface }});
} }
my $change = 0;
my $cleaned_current_dns = ""; my $cleaned_current_dns = "";
my @current_dns_array = split/,/, $current_dns; my @current_dns_array = split/,/, $current_dns;
foreach my $this_current_dns (sort {$a cmp $b} @current_dns_array) foreach my $this_current_dns (sort {$a cmp $b} @current_dns_array)
@ -719,7 +558,6 @@ sub check_local_network
$cleaned_current_dns =~ s/,$//; $cleaned_current_dns =~ s/,$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { cleaned_current_dns => $cleaned_current_dns }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { cleaned_current_dns => $cleaned_current_dns }});
my $change = 0;
if (($current_ip ne $ip) or ($current_subnet ne $subnet)) if (($current_ip ne $ip) or ($current_subnet ne $subnet))
{ {
# IP / subnet changed. # IP / subnet changed.
@ -737,22 +575,30 @@ sub check_local_network
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }});
} }
# Check DNS only if gateway is set. # Check DNS only if this is the default gateway interface.
if ($gateway) $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
in_iface => $in_iface,
default_gateway_interface => $default_gateway_interface,
cleaned_current_dns => $cleaned_current_dns,
}});
if ($in_iface eq $default_gateway_interface)
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
cleaned_current_dns => $cleaned_current_dns,
cleaned_dns => $cleaned_dns,
}});
if ($cleaned_dns ne $cleaned_current_dns) if ($cleaned_dns ne $cleaned_current_dns)
{ {
#print "DNS: ... [".$cleaned_current_dns."] -> [".$cleaned_dns."]\n"; #print "DNS: ... [".$cleaned_current_dns."] -> [".$cleaned_dns."]\n";
$change = 1; $change = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }});
} }
elsif (($in_iface eq $default_gateway_interface) && (not $anvil->data->{network}{'local'}{interface}{$in_iface}{default_gateway})) }
{ elsif ($cleaned_current_dns)
# This isn't the default gateway yet, but we'll make it so. {
#print "Will set as default gateway\n"; # Remove the old DNS entries.
$change = 1; $change = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { change => $change }});
}
} }
if (not $change) if (not $change)
@ -907,6 +753,15 @@ sub check_local_network
elsif ($line =~ /^GATEWAY=".*"/) elsif ($line =~ /^GATEWAY=".*"/)
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { gateway_seen => $gateway_seen }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { gateway_seen => $gateway_seen }});
if ($in_iface ne $default_gateway_interface)
{
# This interface shouldn't have DNS.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0111", variables => {
interface => $in_iface,
gateway_line => $line,
}});
next;
}
if (not $gateway_seen) if (not $gateway_seen)
{ {
$gateway_seen = 1; $gateway_seen = 1;
@ -918,13 +773,23 @@ sub check_local_network
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { gateway_seen => $gateway_seen }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { gateway_seen => $gateway_seen }});
} }
elsif ($line =~ /^DNS=".*"/) elsif ($line =~ /^DNS\d+=".*"/)
{ {
# The first time we see a DNS entry, we inject the DNS we've # The first time we see a DNS entry, we inject the DNS we've
# got and then ignore the rest. # got and then ignore the rest.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dns_seen => $dns_seen }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { dns_seen => $dns_seen }});
if ($in_iface ne $default_gateway_interface)
{
# This interface shouldn't have DNS.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0110", variables => {
interface => $in_iface,
dns_line => $line,
}});
next;
}
if (not $dns_seen) if (not $dns_seen)
{ {
# If there's no DNS, this will do nothing. # If there's no DNS, this will do nothing.
my $i = 1; my $i = 1;
foreach my $this_dns (split/,/, $cleaned_dns) foreach my $this_dns (split/,/, $cleaned_dns)
@ -932,7 +797,6 @@ sub check_local_network
$new_config .= "DNS".$i."=\"".$this_dns."\"\n"; $new_config .= "DNS".$i."=\"".$this_dns."\"\n";
$i++; $i++;
} }
$dns_seen = 1; $dns_seen = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:dns_seen' => $dns_seen, 's1:dns_seen' => $dns_seen,
@ -1001,21 +865,24 @@ sub check_local_network
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }});
} }
if (not $gateway_seen) if ($in_iface eq $default_gateway_interface)
{ {
$new_config .= "GATEWAY=\"".$gateway."\"\n"; if (not $gateway_seen)
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }});
}
if (not $dns_seen)
{
# If there's no DNS, this will do nothing.
my $i = 1;
foreach my $this_dns (split/,/, $cleaned_dns)
{ {
$new_config .= "DNS".$i."=\"".$this_dns."\"\n"; $new_config .= "GATEWAY=\"".$gateway."\"\n";
$i++; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }});
}
if (not $dns_seen)
{
# If there's no DNS, this will do nothing.
my $i = 1;
foreach my $this_dns (split/,/, $cleaned_dns)
{
$new_config .= "DNS".$i."=\"".$this_dns."\"\n";
$i++;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { new_config => $new_config }});
} }
if (not $mtu_seen) if (not $mtu_seen)
{ {
@ -1031,11 +898,6 @@ sub check_local_network
# Write out the new file. # Write out the new file.
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0083,!!file!".$filename."!!"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0083,!!file!".$filename."!!");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0083", variables => { file => $filename }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0083", variables => { file => $filename }});
# print "File about to write: [".$filename."]\n";
# print "============================\n";
# print $new_config."\n";
# print "============================\n";
# die "There's a bug here that is re-writting the config with duplicate DNS and something the wrong IP for this host.\n";
$anvil->Storage->write_file({ $anvil->Storage->write_file({
debug => 3, debug => 3,
file => $filename, file => $filename,
@ -1062,7 +924,7 @@ sub check_local_network
# Tell nmcli to re-read the config files. # Tell nmcli to re-read the config files.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0463"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0463"});
my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection reload"}); my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection reload"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
@ -1071,10 +933,10 @@ sub check_local_network
foreach my $interface_name (sort {$a cmp $b} @{$restart_interfaces}) foreach my $interface_name (sort {$a cmp $b} @{$restart_interfaces})
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0462", variables => { interface => $interface_name }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0462", variables => { interface => $interface_name }});
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection down \"".$interface_name."\""}); $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection down \"".$interface_name."\""});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0464", variables => { interface => $interface_name }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0464", variables => { interface => $interface_name }});
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection up \"".$interface_name."\""}); $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection up \"".$interface_name."\""});
} }
# Wait for a DB connection. We'll wait up to 130 seconds (updelay is 120 seconds, plus a small buffer). # Wait for a DB connection. We'll wait up to 130 seconds (updelay is 120 seconds, plus a small buffer).
@ -1109,8 +971,8 @@ sub check_local_network
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0085"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0085"});
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0085"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0085");
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{virsh}." net-destroy default"}); $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{virsh}." net-destroy default"});
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{virsh}." net-undefine default "}); $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{virsh}." net-undefine default "});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0034"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0034"});
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0034"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0034");
@ -1153,7 +1015,7 @@ sub check_local_network
}}); }});
# Change the live MTU. # Change the live MTU.
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$in_iface." mtu ".$mtu}); $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$in_iface." mtu ".$mtu});
# Now update the config file. # Now update the config file.
my $interface_uuid = $anvil->data->{nmcli}{'local'}{device_to_uuid}{$in_iface}; my $interface_uuid = $anvil->data->{nmcli}{'local'}{device_to_uuid}{$in_iface};
@ -1191,11 +1053,6 @@ sub check_local_network
# Write out the new file. # Write out the new file.
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0083,!!file!".$filename."!!"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0083,!!file!".$filename."!!");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0083", variables => { file => $filename }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0083", variables => { file => $filename }});
# print "File about to write: [".$filename."]\n";
# print "============================\n";
# print $new_config."\n";
# print "============================\n";
# die "There's a bug here that is re-writting the config with duplicate DNS and something the wrong IP for this host.\n";
$anvil->Storage->write_file({ $anvil->Storage->write_file({
debug => 2, debug => 2,
file => $filename, file => $filename,
@ -1272,24 +1129,26 @@ sub check_local_network
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0091,!!daemon!".$daemon."!!"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0091,!!daemon!".$daemon."!!");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0091", variables => { daemon => $daemon }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0091", variables => { daemon => $daemon }});
$anvil->System->restart_daemon({ $anvil->System->restart_daemon({
debug => 2, debug => 3,
daemon => $daemon, daemon => $daemon,
}) })
} }
} }
# Make sure the IPs of the dashboard(s) and our peers are in the hosts file. # Update the hosts file.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0112"});
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0112");
$anvil->System->update_hosts({debug => 3});
### TODO: Do we really need passwordless SSH anymore?
# Configure SSH by adding ours and our peer's SSH keys to ~/.ssh/known_hosts # Configure SSH by adding ours and our peer's SSH keys to ~/.ssh/known_hosts
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0113"});
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0113");
$anvil->System->check_ssh_keys({debug => 3}); $anvil->System->check_ssh_keys({debug => 3});
# Update the hosts file.
$anvil->System->update_hosts({debug => 3});
# Setup IPMI, if needed. # Setup IPMI, if needed.
### TODO: Do this when on real hardware $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0114"});
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0114");
$anvil->System->configure_ipmi({debug => 3, manifest_uuid => $manifest_uuid});
return(0); return(0);
} }

@ -21,6 +21,7 @@ my $anvil = Anvil::Tools->new();
$anvil->Log->level({set => 2}); $anvil->Log->level({set => 2});
$anvil->Log->secure({set => 0}); $anvil->Log->secure({set => 0});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Get->switches;
# If there's no DB (or cached data isn't recorded to the database yet), this will store those records. # If there's no DB (or cached data isn't recorded to the database yet), this will store those records.
$anvil->data->{cache}{new_file} = "# interface,timestamp,mac_address,speed,link_state,operational\n"; $anvil->data->{cache}{new_file} = "# interface,timestamp,mac_address,speed,link_state,operational\n";
@ -121,7 +122,7 @@ sub update_network
my ($anvil) = @_; my ($anvil) = @_;
# Run 'ip addr' to see what IPs are in use. # Run 'ip addr' to see what IPs are in use.
$anvil->Network->get_ips({debug => 3}); $anvil->Network->get_ips();
# We'll read through '/sys/class/net' looking for network interfaces. # We'll read through '/sys/class/net' looking for network interfaces.
# * 'network::local::interface::<iface_name>::ip' - If an IP address is set # * 'network::local::interface::<iface_name>::ip' - If an IP address is set
@ -457,7 +458,7 @@ sub update_network
# recording interfaces. # recording interfaces.
foreach my $processing ("bridge", "bond", "interface") foreach my $processing ("bridge", "bond", "interface")
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { processing => $processing }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { processing => $processing }});
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}})
{ {
# Skip if this isn't the device type we're working on. # Skip if this isn't the device type we're working on.
@ -492,7 +493,7 @@ sub update_network
my $default_gateway = $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway}; my $default_gateway = $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway};
my $gateway = $anvil->data->{network}{'local'}{interface}{$interface}{gateway}; my $gateway = $anvil->data->{network}{'local'}{interface}{$interface}{gateway};
my $dns = $anvil->data->{network}{'local'}{interface}{$interface}{dns}; my $dns = $anvil->data->{network}{'local'}{interface}{$interface}{dns};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
active_interface => $active_interface, active_interface => $active_interface,
bond_mode => $bond_mode, bond_mode => $bond_mode,
bond_master => $bond_master, bond_master => $bond_master,

@ -29,7 +29,4 @@ $anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, secure => 0, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, secure => 0, key => "log_0132"});
$anvil->Get->switches; $anvil->Get->switches;
$anvil->System->configure_ipmi({ $anvil->System->check_ssh_keys({debug => 2});
debug => 2,
manifest_uuid => "6115d040-bdc4-4c76-9514-15870d88fb43",
});

Loading…
Cancel
Save