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

31 lines
899 B
YAML

---
- hosts: localhost
gather_facts: true
vars:
repo: "repo_name"
root_dir: "/path/to/svn_repo_dir"
tasks:
- name: update {{repo}} from svn
shell: cd {{root_dir}}/{{repo}} && svn update {{repo}}.zip &>> {{ansible_env.SSH_TTY}}
- hosts: "{{host}}"
gather_facts: false
vars:
repo: "repo_name"
root_dir: "/path/to/svn_repo_dir"
remote_dir: "/path/to/deploy_dir"
tasks:
- name: upload {{repo}}.zip
copy: src={{root_dir}}/{{repo}}/{{repo}}.zip dest={{remote_dir}}/{{repo}}.zip
- name: check whether {{repo}} exists
shell: ls -d {{repo}} || true
args:
chdir: "{{remote_dir}}"
register: repo_exists
- name: create bakup
shell: cd {{remote_dir}} && rm -rf {{repo}}.bak && mv {{repo}} {{repo}}.bak
when: repo_exists.stdout != ''
- name: create new {{repo}}
shell: cd {{remote_dir}} && unzip {{repo}}.zip && rm -f {{repo}}.zip