Ansible playbook for provisioning and deploying a Rails/MySQL app to an Ubuntu server
Would you take a quick second and ⭐️ my repo?
This project is an Ansible playbook for provisioning and deploying a Rails/MySQL app to an Ubuntu server. It is intended to be added to an existing Rails application folder. Tested with: Rails 5.1.5, Ruby 2.4.3, Ubuntu 16.04 (Xenial).
Ansible >= 2.4.1 must be installed
This playbook assumes you are targeting MySQL for your production database and have gem 'mysql2'
included in your Gemfile.
From your Rails application folder run:
\curl -sSL https://raw.githubusercontent.com/bradymholt/ansible-rails/master/installer.sh | bash
which will:
provision
and deploy
.If you would prefer, you can run the commands in this file manually.
Edit the ops/config.yml
file and add your project configuration
Provisioning is used to to setup the the server and initially deploy the application.
To provision your server, run: rake provision
. This will do the following:
SECRET_KEY_BASE
with a unique uuid value.rake assets:precompile
.config/database.yml
on remote server with correct production db configbundle install
rake db:migrate RAILS_ENV="production"
rake tmp:clear
rake log:clear
touch tmp/restart.txt
(restart the app)If you have already provisioned your server and want to redeploy changes to your Rails app, run rake deploy
. This will only run the deploy tasks from the playbook and be much faster.