diff --git a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/exec_init_runtime.sh b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/exec_init_runtime.sh index 5a83be7d..8e5be9b6 100644 --- a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/exec_init_runtime.sh +++ b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/exec_init_runtime.sh @@ -22,9 +22,5 @@ fi ansible-playbook -i ${hosts_path} ${init_runtime_path} -e "var_files_path=${config_path}" 2>&1>>/tmp/init_runtime.log init_runtime_exit_code=$? if [ $init_runtime_exit_code -ne 0 ];then - echo "Warning: init runtime failed, return code:${init_runtime_exit_code}" - ansible-playbook -i ${hosts_path} ${rollback_path} 2>&1>>/tmp/init_runtime.log - rollback_exit_code=$? - echo "Warning: rollback failed, return code:${rollback_exit_code}" exit 1 fi \ No newline at end of file diff --git a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/exec_rollback.sh b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/exec_rollback.sh new file mode 100644 index 00000000..f39a9e4c --- /dev/null +++ b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/exec_rollback.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +backup_config_path=/data/init_runtime/backup/runtime.yml +hosts_path=/opt/tsg/init_runtime/hosts +rollback_path=/opt/tsg/init_runtime/tasks/init_runtime.yml + +rollback_exit_code=0 + + +ansible-playbook -i ${hosts_path} ${rollback_path} -e "var_files_path=${backup_config_path}" +if [ $rollback_exit_code -ne 0 ];then + exit 1 +fi \ No newline at end of file diff --git a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/handlers/restart_service.yml b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/handlers/restart_service.yml deleted file mode 100644 index 769a98a4..00000000 --- a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/handlers/restart_service.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: "Restart certstore" - systemd: - name: certstore - state: restarted - -- name: "Restart sapp" - systemd: - name: sapp - state: restarted - -- name: "Restart telegraf_statistic" - systemd: - name: telegraf_statistic - state: restarted - -- name: "Restart tfe" - systemd: - name: tfe - state: restarted diff --git a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/tasks/backup_conf.yml b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/tasks/backup_conf.yml index c9470238..1554a016 100644 --- a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/tasks/backup_conf.yml +++ b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/tasks/backup_conf.yml @@ -1,51 +1,7 @@ --- - hosts: local tasks: - - name: "backup_conf: backup certstore configure file" + - name: "backup_conf: backup the stage2 config files" copy: - src: /opt/tsg/certstore/conf/cert_store.ini + src: /data/init_runtime/runtime.yml dest: /data/init_runtime/backup/ - tags: certstore - - - name: "backup_conf: backup the tsgconf/main.conf" - copy: - src: /home/mesasoft/sapp_run/tsgconf/main.conf - dest: /data/init_runtime/backup/ - tags: firewall - - - name: "backup_conf: backup the tsgconf/maat.conf" - copy: - src: /home/mesasoft/sapp_run/tsgconf/maat.conf - dest: /data/init_runtime/backup/ - tags: firewall - - - name: "backup_conf: backup the conf/capture_packet_plug.conf" - copy: - src: /home/mesasoft/sapp_run/conf/capture_packet_plug.conf - dest: /data/init_runtime/backup/ - tags: firewall - - - name: "backup_conf: backup the sapp.toml" - copy: - src: /home/mesasoft/sapp_run/etc/sapp.toml - dest: /data/init_runtime/backup/ - tags: sapp - - - name: "backup_conf: backup telegraf.conf" - copy: - src: /etc/telegraf/telegraf_statistic.conf - dest: /data/init_runtime/backup/ - tags: telegraf_statistic - - - name: "backup_conf: backup the tfe.conf" - copy: - src: /opt/tsg/tfe/conf/tfe/tfe.conf - dest: /data/init_runtime/backup/ - tags: tfe - - - name: "backup_conf: backup the pangu_pxy.conf" - copy: - src: /opt/tsg/tfe/conf/pangu/pangu_pxy.conf - dest: /data/init_runtime/backup/ - tags: tfe - diff --git a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/tasks/rollback_conf.yml b/tsg-9140-scripts/roles/init_runtime/files/init_runtime/tasks/rollback_conf.yml deleted file mode 100644 index 2273a2f8..00000000 --- a/tsg-9140-scripts/roles/init_runtime/files/init_runtime/tasks/rollback_conf.yml +++ /dev/null @@ -1,70 +0,0 @@ ---- -- hosts: local - tasks: - - name: "rollback_conf: rollback certstore configure file" - copy: - src: /data/init_runtime/backup/cert_store.ini - dest: /opt/tsg/certstore/conf/cert_store.ini - notify: - - Restart certstore - tags: certstore - - - name: "rollback_conf: rollback the tsgconf/main.conf" - copy: - src: /data/init_runtime/backup/main.conf - dest: /home/mesasoft/sapp_run/tsgconf/main.conf - notify: - - Restart sapp - tags: firewall - - - name: "rollback_conf: rollback the tsgconf/maat.conf" - copy: - src: /data/init_runtime/backup/maat.conf - dest: /home/mesasoft/sapp_run/tsgconf/maat.conf - notify: - - Restart sapp - tags: firewall - - - name: "rollback_conf: rollback the conf/capture_packet_plug.conf" - copy: - src: /data/init_runtime/backup/capture_packet_plug.conf - dest: /home/mesasoft/sapp_run/conf/capture_packet_plug.conf - notify: - - Restart sapp - tags: firewall - - - name: "rollback_conf: rollback the sapp.toml" - copy: - src: /data/init_runtime/backup/sapp.toml - dest: /home/mesasoft/sapp_run/etc/sapp.toml - notify: - - Restart sapp - tags: sapp - - - name: "rollback_conf: rollback telegraf.conf" - copy: - src: /data/init_runtime/backup/telegraf_statistic.conf - dest: /etc/telegraf/telegraf_statistic.conf - notify: - - Restart telegraf_statistic - tags: telegraf_statistic - - - name: "rollback_conf: rollback the tfe.conf" - copy: - src: /data/init_runtime/backup/tfe.conf - dest: /opt/tsg/tfe/conf/tfe/tfe.conf - notify: - - Restart tfe - tags: tfe - - - name: "rollback_conf: rollback the pangu_pxy.conf" - copy: - src: /data/init_runtime/backup/pangu_pxy.conf - dest: /opt/tsg/tfe/conf/pangu/pangu_pxy.conf - notify: - - Restart tfe - tags: tfe - - handlers: - - include: ../handlers/restart_service.yml -