修改stage2 的init_runtime 执行流程,新增stage2 rollback功能

This commit is contained in:
fumingwei
2021-05-20 11:45:21 +08:00
parent 234ee70352
commit b82f67a5b7
5 changed files with 15 additions and 140 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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