@@ -696,7 +696,7 @@ ln -sf "${SSH_AUTH_SOCK}" /run/host-services/ssh-auth.sock`
696696 // Copy all config files _after_ the requirements are done
697697 for _ , rule := range a .instConfig .CopyToHost {
698698 sshAddress , sshPort := a .sshAddressPort ()
699- if err := copyToHost (ctx , a .sshConfig , sshAddress , sshPort , rule .HostFile , rule .GuestFile ); err != nil {
699+ if err := copyToHost (ctx , a .sshConfig , sshAddress , sshPort , rule .HostFile , rule .GuestFile , rule . SkipIfMissing ); err != nil {
700700 errs = append (errs , err )
701701 }
702702 }
@@ -1266,7 +1266,7 @@ func isDeactivatedCloudInitMainService(line string) bool {
12661266 return strings .HasPrefix (line , "cloud-init-main.service: consumed" )
12671267}
12681268
1269- func copyToHost (ctx context.Context , sshConfig * ssh.SSHConfig , sshAddress string , sshPort int , local , remote string ) error {
1269+ func copyToHost (ctx context.Context , sshConfig * ssh.SSHConfig , sshAddress string , sshPort int , local , remote string , skipIfMissing bool ) error {
12701270 args := sshConfig .Args ()
12711271 args = append (args ,
12721272 "-p" , strconv .Itoa (sshPort ),
@@ -1296,6 +1296,12 @@ func copyToHost(ctx context.Context, sshConfig *ssh.SSHConfig, sshAddress string
12961296 cmd = exec .CommandContext (ctx , sshConfig .Binary (), sudoArgs ... )
12971297 out , err = cmd .Output ()
12981298 }
1299+ if errors .As (err , & exitErr ) && strings .Contains (string (exitErr .Stderr ), "No such file or directory" ) {
1300+ if skipIfMissing {
1301+ logrus .Infof ("Skip missing %s (no such file or directory)" , remote )
1302+ return nil
1303+ }
1304+ }
12991305 if err != nil {
13001306 return fmt .Errorf ("failed to run %v: %#q: %w" , cmd .Args , string (out ), err )
13011307 }
0 commit comments