fix: выход если ошибка в Ansible
This commit is contained in:
@@ -21,7 +21,7 @@ var (
|
|||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "playbookctl",
|
Use: "playbookctl",
|
||||||
Short: "Ansible Playbook Dedic2 Control",
|
Short: "Ansible Playbook Dedic2 Control",
|
||||||
Version: "4.0.2",
|
Version: "4.0.3",
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
return cmd.Help()
|
return cmd.Help()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ func (app *SpaceWorker) Restore(targetHost string, timestamp string, inventory s
|
|||||||
app.log.Info(fmt.Sprintf("Target Host: %s", host))
|
app.log.Info(fmt.Sprintf("Target Host: %s", host))
|
||||||
|
|
||||||
app.log.Info("Pre restore Ansible")
|
app.log.Info("Pre restore Ansible")
|
||||||
_ = command.Run()
|
err = command.Run()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
app.log.Info("Send files")
|
app.log.Info("Send files")
|
||||||
command = exec.Command("/bin/bash", "-c", preRestoreFile)
|
command = exec.Command("/bin/bash", "-c", preRestoreFile)
|
||||||
@@ -59,7 +62,10 @@ func (app *SpaceWorker) Restore(targetHost string, timestamp string, inventory s
|
|||||||
command.Stdin = os.Stdin
|
command.Stdin = os.Stdin
|
||||||
command.Stdout = os.Stdout
|
command.Stdout = os.Stdout
|
||||||
command.Stderr = os.Stderr
|
command.Stderr = os.Stderr
|
||||||
_ = command.Run()
|
err = command.Run()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
app.log.Info("Clean temp files")
|
app.log.Info("Clean temp files")
|
||||||
command = exec.Command("/bin/bash", "-c", preRestoreFile+"_clean")
|
command = exec.Command("/bin/bash", "-c", preRestoreFile+"_clean")
|
||||||
@@ -67,7 +73,10 @@ func (app *SpaceWorker) Restore(targetHost string, timestamp string, inventory s
|
|||||||
command.Stdin = os.Stdin
|
command.Stdin = os.Stdin
|
||||||
command.Stdout = os.Stdout
|
command.Stdout = os.Stdout
|
||||||
command.Stderr = os.Stderr
|
command.Stderr = os.Stderr
|
||||||
_ = command.Run()
|
err = command.Run()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err = utils.RemoveFile(preRestoreFile); err != nil {
|
if err = utils.RemoveFile(preRestoreFile); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user