Ansible notes
Ansible 是基于 SSH 的自动化配置管理和部署工具,更多请参考官方文档。
ansible -i hosts.ini all -m ping
ansible-playbook -i hosts.ini playbook.yaml
用 Ansible + Supervisor 部署/更新应用:
- hosts: server
tasks:
- name: check if exists
stat: path=/path/to/app
register: check_path
- name: clone
shell: git clone XXX && git checkout -b release
when: check_path.stat.exists == false
- name: pull
shell: cd /path/to/app && git pull origin release
when: check_path.stat.exists
- name: is already running ?
stat: path=/tmp/supervisord.pid
register: supervisord_stat
- name: restart
command: supervisorctl -c supervisord.conf restart all
args:
chdir: /path/to/app
when: supervisord_stat.stat.exists
- name: start
command: supervisord -c supervisord.conf
args:
chdir: /path/to/app
when: supervisord_stat.stat.exists == false
Was this page helpful?