Created
May 5, 2014 14:36
-
-
Save pote/36b8c97bd6fc3bb7f242 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: web | |
sudo: yes | |
accelerate: true | |
vars: | |
app_dir: "/var/www/the_application_name_goes_here" | |
server_env: | |
RACK_ENV: "production" | |
SSO_SALT: "esta no es la salt de verdad" | |
REDIS_URL: "redis://rest_of_url" | |
GEM_HOME: "{{ app_dir }}/.gs" | |
tasks: | |
- name: Creates directory for the application and its dependencies | |
command: "mkdir -p {{ app_dir }}/.gs" | |
- name: Set user/permissions for app directory | |
file: owner=ubuntu | |
path={{ app_dir }} | |
recurse=yes | |
mode=0777 | |
- name: Use git to checkout the desired webapp version. | |
git: [email protected]:organization/repo.git | |
version={{ git_revision | default("HEAD") }} | |
dest={{ app_dir }} | |
key_file="/home/ubuntu/.ssh/identity_file_copied_on_provisioning.pem" | |
accept_hostkey=True | |
depth=1 | |
- name: Install ruby dependencies | |
environment: server_env | |
command: chdir={{ app_dir }} | |
dep install | |
- name: Getting the unicorn pid | |
shell: "cat {{ app_dir }}/tmp/unicorn.pid" | |
register: unicorn_pid | |
ignore_errors: True | |
- name: Instruct Unicorn to reload the code if its running | |
environment: server_env | |
when: unicorn_pid|success | |
command: 'kill -HUP {{ unicorn_pid.stdout }}' | |
- name: Start Unicorn daemon when its not | |
environment: server_env | |
when: unicorn_pid|failed | |
shell: chdir={{ app_dir }} | |
unicorn -D -c unicorn.rb -E production |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment