@@ -1316,19 +1316,12 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
1316
1316
public_ip : public_ip,
1317
1317
} ;
1318
1318
println ! ( "\n {}\n " , ssh_command. to_string( ) ) ;
1319
-
1320
- let output = ssh_command
1321
- . run ( "tail -10 /var/log/cloud-init-output.log" )
1322
- . unwrap ( ) ;
1323
- println ! ( "init script std output:\n {}\n " , output. stdout) ;
1324
- println ! ( "init script std err:\n {}\n " , output. stderr) ;
1325
-
1326
1319
ssh_commands. push ( ssh_command) ;
1327
1320
}
1328
1321
println ! ( ) ;
1329
1322
1330
- ec2:: SshCommands ( ssh_commands)
1331
- . sync ( & regional_resource. ssh_commands_path )
1323
+ ec2:: SshCommands ( ssh_commands. clone ( ) )
1324
+ . sync ( & regional_resource. ssh_commands_path_anchor_nodes )
1332
1325
. unwrap ( ) ;
1333
1326
1334
1327
// wait for anchor nodes to generate certs and node ID and post to remote storage
@@ -1410,6 +1403,20 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
1410
1403
1411
1404
log:: info!( "waiting for anchor nodes bootstrap and ready (to be safe)" ) ;
1412
1405
sleep ( Duration :: from_secs ( 15 ) ) . await ;
1406
+
1407
+ for ssh_command in ssh_commands. iter ( ) {
1408
+ let output = ssh_command
1409
+ . run ( "tail -10 /var/log/cloud-init-output.log" )
1410
+ . unwrap ( ) ;
1411
+ println ! (
1412
+ "{} (anchor node) init script std output:\n {}\n " ,
1413
+ ssh_command. instance_id, output. stdout
1414
+ ) ;
1415
+ println ! (
1416
+ "{} (anchor node) init script std err:\n {}\n " ,
1417
+ ssh_command. instance_id, output. stderr
1418
+ ) ;
1419
+ }
1413
1420
}
1414
1421
}
1415
1422
@@ -1748,60 +1755,41 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
1748
1755
}
1749
1756
}
1750
1757
1751
- println ! ( ) ;
1752
1758
let f = File :: open ( & regional_resource. ec2_key_path ) . unwrap ( ) ;
1753
1759
f. set_permissions ( PermissionsExt :: from_mode ( 0o444 ) ) . unwrap ( ) ;
1760
+
1761
+ println ! ( ) ;
1762
+ let mut ssh_commands = Vec :: new ( ) ;
1754
1763
for d in droplets {
1755
- let ( instance_ip , ip_kind ) =
1764
+ let ( public_ip , ip_mode ) =
1756
1765
if let Some ( public_ip) = instance_id_to_public_ip. get ( & d. instance_id ) {
1757
1766
( public_ip. clone ( ) , "elastic" )
1758
1767
} else {
1759
1768
( d. public_ipv4 . clone ( ) , "ephemeral" )
1760
1769
} ;
1761
- // ssh -o "StrictHostKeyChecking no" -i [ec2_key_path] [user name]@[public IPv4/DNS name]
1762
- // aws ssm start-session --region [region] --target [instance ID]
1763
- println ! (
1764
- "# change SSH key permission
1765
- chmod 400 {}
1766
- # instance '{}' ({}, {}) -- IP kind {}
1767
- ssh -o \" StrictHostKeyChecking no\" -i {} ubuntu@{}
1768
- # download to local machine
1769
- scp -i {} ubuntu@{}:REMOTE_FILE_PATH LOCAL_FILE_PATH
1770
- scp -i {} -r ubuntu@{}:REMOTE_DIRECTORY_PATH LOCAL_DIRECTORY_PATH
1771
- # upload to remote machine
1772
- scp -i {} LOCAL_FILE_PATH ubuntu@{}:REMOTE_FILE_PATH
1773
- scp -i {} -r LOCAL_DIRECTORY_PATH ubuntu@{}:REMOTE_DIRECTORY_PATH
1774
- # SSM session (requires SSM agent)
1775
- aws ssm start-session --region {} --target {}
1776
- " ,
1777
- regional_resource. ec2_key_path,
1778
- //
1779
- d. instance_id,
1780
- d. instance_state_name,
1781
- d. availability_zone,
1782
- ip_kind,
1783
- //
1784
- regional_resource. ec2_key_path,
1785
- instance_ip,
1786
- //
1787
- regional_resource. ec2_key_path,
1788
- instance_ip,
1789
- //
1790
- regional_resource. ec2_key_path,
1791
- instance_ip,
1792
- //
1793
- regional_resource. ec2_key_path,
1794
- instance_ip,
1795
- //
1796
- regional_resource. ec2_key_path,
1797
- instance_ip,
1798
- //
1799
- regional_resource. region,
1800
- d. instance_id,
1801
- ) ;
1770
+
1771
+ let ssh_command = ec2:: SshCommand {
1772
+ ec2_key_path : regional_resource. ec2_key_path . clone ( ) ,
1773
+ user_name : String :: from ( "ubuntu" ) ,
1774
+
1775
+ region : region. clone ( ) ,
1776
+ availability_zone : d. availability_zone ,
1777
+
1778
+ instance_id : d. instance_id ,
1779
+ instance_state_name : d. instance_state_name ,
1780
+
1781
+ ip_mode : ip_mode. to_string ( ) ,
1782
+ public_ip : public_ip,
1783
+ } ;
1784
+ println ! ( "\n {}\n " , ssh_command. to_string( ) ) ;
1785
+ ssh_commands. push ( ssh_command) ;
1802
1786
}
1803
1787
println ! ( ) ;
1804
1788
1789
+ ec2:: SshCommands ( ssh_commands. clone ( ) )
1790
+ . sync ( & regional_resource. ssh_commands_path_non_anchor_nodes )
1791
+ . unwrap ( ) ;
1792
+
1805
1793
// wait for non anchor nodes to generate certs and node ID and post to remote storage
1806
1794
// TODO: set timeouts
1807
1795
let mut regional_non_anchor_nodes = Vec :: new ( ) ;
@@ -1877,6 +1865,20 @@ aws ssm start-session --region {} --target {}
1877
1865
1878
1866
log:: info!( "waiting for non-anchor nodes bootstrap and ready (to be safe)" ) ;
1879
1867
sleep ( Duration :: from_secs ( 20 ) ) . await ;
1868
+
1869
+ for ssh_command in ssh_commands. iter ( ) {
1870
+ let output = ssh_command
1871
+ . run ( "tail -10 /var/log/cloud-init-output.log" )
1872
+ . unwrap ( ) ;
1873
+ println ! (
1874
+ "{} (non-anchor node) init script std output:\n {}\n " ,
1875
+ ssh_command. instance_id, output. stdout
1876
+ ) ;
1877
+ println ! (
1878
+ "{} (non-anchor node) init script std err:\n {}\n " ,
1879
+ ssh_command. instance_id, output. stderr
1880
+ ) ;
1881
+ }
1880
1882
}
1881
1883
}
1882
1884
@@ -2756,8 +2758,6 @@ default-spec --log-level=info --funded-keys={funded_keys} --region={region} --up
2756
2758
instance_id_to_public_ip. insert ( instance_id, public_ip) ;
2757
2759
}
2758
2760
2759
- let ec2_key_path = regional_resource. ec2_key_path . clone ( ) ;
2760
-
2761
2761
let user_name = {
2762
2762
if dev_machine. os_type == "al2" {
2763
2763
"ec2-user"
@@ -2766,6 +2766,7 @@ default-spec --log-level=info --funded-keys={funded_keys} --region={region} --up
2766
2766
}
2767
2767
} ;
2768
2768
2769
+ let mut ssh_commands = Vec :: new ( ) ;
2769
2770
for d in droplets {
2770
2771
// ssh -o "StrictHostKeyChecking no" -i [ec2_key_path] [user name]@[public IPv4/DNS name]
2771
2772
// aws ssm start-session --region [region] --target [instance ID]
@@ -2776,54 +2777,28 @@ default-spec --log-level=info --funded-keys={funded_keys} --region={region} --up
2776
2777
d. public_ipv4 . clone ( )
2777
2778
} ;
2778
2779
2779
- println ! (
2780
- "
2781
- # change SSH key permission
2782
- chmod 400 {}
2783
- # instance '{}' ({}, {}) -- ip mode '{}'
2784
- ssh -o \" StrictHostKeyChecking no\" -i {} {}@{}
2785
- # download to local machine
2786
- scp -i {} {}@{}:REMOTE_FILE_PATH LOCAL_FILE_PATH
2787
- scp -i {} -r {}@{}:REMOTE_DIRECTORY_PATH LOCAL_DIRECTORY_PATH
2788
- # upload to remote machine
2789
- scp -i {} LOCAL_FILE_PATH {}@{}:REMOTE_FILE_PATH
2790
- scp -i {} -r LOCAL_DIRECTORY_PATH {}@{}:REMOTE_DIRECTORY_PATH
2791
- # SSM session (requires SSM agent)
2792
- aws ssm start-session --region {} --target {}
2793
- " ,
2794
- ec2_key_path,
2795
- //
2796
- d. instance_id,
2797
- d. instance_state_name,
2798
- d. availability_zone,
2799
- spec. machine. ip_mode,
2800
- //
2801
- ec2_key_path,
2802
- user_name,
2803
- public_ip,
2804
- //
2805
- ec2_key_path,
2806
- user_name,
2807
- public_ip,
2808
- //
2809
- ec2_key_path,
2810
- user_name,
2811
- public_ip,
2812
- //
2813
- ec2_key_path,
2814
- user_name,
2815
- public_ip,
2816
- //
2817
- ec2_key_path,
2818
- user_name,
2819
- public_ip,
2820
- //
2821
- spec. resource. regions[ 0 ] ,
2822
- d. instance_id,
2823
- ) ;
2780
+ let ssh_command = ec2:: SshCommand {
2781
+ ec2_key_path : regional_resource. ec2_key_path . clone ( ) ,
2782
+ user_name : user_name. to_string ( ) ,
2783
+
2784
+ region : spec. resource . regions [ 0 ] . clone ( ) ,
2785
+ availability_zone : d. availability_zone ,
2786
+
2787
+ instance_id : d. instance_id ,
2788
+ instance_state_name : d. instance_state_name ,
2789
+
2790
+ ip_mode : spec. machine . ip_mode . clone ( ) ,
2791
+ public_ip : public_ip,
2792
+ } ;
2793
+ println ! ( "\n {}\n " , ssh_command. to_string( ) ) ;
2794
+ ssh_commands. push ( ssh_command) ;
2824
2795
}
2825
2796
println ! ( ) ;
2826
2797
2798
+ ec2:: SshCommands ( ssh_commands. clone ( ) )
2799
+ . sync ( & regional_resource. ssh_commands_path_dev_machine )
2800
+ . unwrap ( ) ;
2801
+
2827
2802
spec. resource
2828
2803
. regional_resources
2829
2804
. insert ( spec. resource . regions [ 0 ] . clone ( ) , regional_resource) ;
@@ -2848,6 +2823,21 @@ aws ssm start-session --region {} --target {}
2848
2823
. await
2849
2824
. unwrap ( ) ;
2850
2825
2826
+ sleep ( Duration :: from_secs ( 10 ) ) . await ;
2827
+ for ssh_command in ssh_commands. iter ( ) {
2828
+ let output = ssh_command
2829
+ . run ( "tail -10 /var/log/cloud-init-output.log" )
2830
+ . unwrap ( ) ;
2831
+ println ! (
2832
+ "{} (dev machine) init script std output:\n {}\n " ,
2833
+ ssh_command. instance_id, output. stdout
2834
+ ) ;
2835
+ println ! (
2836
+ "{} (dev machine) init script std err:\n {}\n " ,
2837
+ ssh_command. instance_id, output. stderr
2838
+ ) ;
2839
+ }
2840
+
2851
2841
//
2852
2842
//
2853
2843
//
0 commit comments