Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JulienSansot/0c9d07fd0ff1667e86a2 to your computer and use it in GitHub Desktop.
Save JulienSansot/0c9d07fd0ff1667e86a2 to your computer and use it in GitHub Desktop.
ansible playbook for deploying a node app on ubuntu
---
- hosts: all
remote_user: ubuntu
vars:
app_repo: [email protected]:****/****.git
app_id: my_app
app_folder: /home/ubuntu/my_app
log_folder: /home/ubuntu/my_app_logs
tasks:
- name: git clone
git: repo={{app_repo}} dest={{app_folder}} accept_hostkey=yes force=yes
register: app_updated
- name: npm install
when: app_updated|changed
npm: path={{app_folder}}
- name: "Restart app"
sudo: yes
when: app_updated|changed
command: forever --uid "{{app_id}}" -al {{log_folder}}/forever.log restart {{app_folder}}/app.js --prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment