my ($ho,$sfx) = @_;
my $authkeys_url= create_webfile($ho, "authkeys$sfx", authorized_keys());
-
- my $hostkeyfile= "$c{OverlayLocal}/etc/ssh/ssh_host_rsa_key.pub";
- my $hostkey= get_filecontents($hostkeyfile);
- chomp($hostkey); $hostkey.="\n";
- my $knownhosts= '';
-
- my $hostsq= $dbh_tests->prepare(<<END);
- SELECT val FROM runvars
- WHERE flight=? AND name LIKE '%host'
- GROUP BY val
-END
- $hostsq->execute($flight);
- while (my ($node) = $hostsq->fetchrow_array()) {
- my $defaultfqdn = $node;
- $defaultfqdn .= ".$c{TestHostDomain}" unless $defaultfqdn =~ m/\./;
-
- my %props;
- $mhostdb->get_properties($node, \%props);
-
- my $longname= $props{Fqdn} // $defaultfqdn;
- my (@hostent)= gethostbyname($longname);
- if (!@hostent) {
- logm("skipping host key for nonexistent host $longname");
- next;
- }
- my $specs= join ',', $longname, $node, map {
- join '.', unpack 'W4', $_;
- } @hostent[4..$#hostent];
- logm("adding host key for $specs");
- $knownhosts.= "$specs ".$hostkey;
- }
- $hostsq->finish();
-
- $knownhosts.= "localhost,127.0.0.1 ".$hostkey;
- my $knownhosts_url= create_webfile($ho, "known_hosts$sfx", $knownhosts);
+ my $knownhosts_url= create_webfile($ho, "known_hosts$sfx", known_hosts());
preseed_hook_command($ho, 'late_command', $sfx, <<END);
#!/bin/sh
store_revision store_vcs_revision
git_massage_url
- sshopts authorized_keys
+ sshopts authorized_keys known_hosts
cfg_tftp_di_version controller_ipaddr
remote_perl_script_open remote_perl_script_done
host_reboot target_reboot target_reboot_hard
return $authkeys;
}
+sub known_hosts () {
+ my $hostkeyfile= "$c{OverlayLocal}/etc/ssh/ssh_host_rsa_key.pub";
+ my $hostkey= get_filecontents($hostkeyfile);
+ chomp($hostkey); $hostkey.="\n";
+
+ my $knownhosts= '';
+
+ my $hostsq= $dbh_tests->prepare(<<END);
+ SELECT val FROM runvars
+ WHERE flight=? AND name LIKE '%host'
+ GROUP BY val
+END
+ $hostsq->execute($flight);
+ while (my ($node) = $hostsq->fetchrow_array()) {
+ my $defaultfqdn = $node;
+ $defaultfqdn .= ".$c{TestHostDomain}" unless $defaultfqdn =~ m/\./;
+
+ my %props;
+ $mhostdb->get_properties($node, \%props);
+
+ my $longname= $props{Fqdn} // $defaultfqdn;
+ my (@hostent)= gethostbyname($longname);
+ if (!@hostent) {
+ logm("skipping host key for nonexistent host $longname");
+ next;
+ }
+ my $specs= join ',', $longname, $node, map {
+ join '.', unpack 'W4', $_;
+ } @hostent[4..$#hostent];
+ logm("adding host key for $specs");
+ $knownhosts.= "$specs ".$hostkey;
+ }
+ $hostsq->finish();
+
+ $knownhosts.= "localhost,127.0.0.1 ".$hostkey;
+
+ return $knownhosts;
+}
+
sub cfg_tftp_di_version ($) {
my ($suite) = @_;
$suite //= 'x def suite'; # will not find $c{...}