ansible/playbooks/web-revert.yml
2021-08-28 23:54:41 +08:00

19 lines
507 B
YAML

- hosts: "{{host}}"
gather_facts: false
vars:
repo: "repo_name"
remote_dir: "/path/to/deploy_dir"
tasks:
- name: check whether {{repo}}.bak exists
shell: ls {{repo}}.bak || true
args:
chdir: "{{remote_dir}}"
register: repo_bak_exists
- name: restore old {{repo}}
shell: cd {{remote_dir}} && rm -rf {{repo}} && mv {{repo}}.bak {{repo}}
when: repo_bak_exists.stdout != ''
- debug:
msg: "Not found {{repo}}.bak, quit"
when: repo_bak_exists.stdout == ''