<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bharani</title>
    <description>The latest articles on DEV Community by Bharani (@bharani91).</description>
    <link>https://dev.to/bharani91</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F375260%2F54283276-a155-4420-a7d4-50b223820936.jpeg</url>
      <title>DEV Community: Bharani</title>
      <link>https://dev.to/bharani91</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bharani91"/>
    <language>en</language>
    <item>
      <title>Ansible Rails -  Deploy Ruby on Rails apps easily</title>
      <dc:creator>Bharani</dc:creator>
      <pubDate>Fri, 12 Jun 2020 07:34:01 +0000</pubDate>
      <link>https://dev.to/bharani91/ansible-rails-deploy-ruby-on-rails-apps-easily-47f8</link>
      <guid>https://dev.to/bharani91/ansible-rails-deploy-ruby-on-rails-apps-easily-47f8</guid>
      <description>&lt;p&gt;I've been using Heroku to deploy my Ruby on Rails apps but I always wanted to learn how it all works under the hood. Over the last couple of months, I decided to learn more about how to set up a server and deploy a Rails app to production. I've made this open-source project called &lt;a href="https://github.com/EmailThis/ansible-rails"&gt;Ansible Rails&lt;/a&gt; in order to consolidate my learning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d0eq0Dkc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gbsyooeu1hwrexm6evp4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d0eq0Dkc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gbsyooeu1hwrexm6evp4.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ansible Rails is an Ansible playbook for easily deploying Ruby on Rails applications. It uses Vagrant to provision an environment where you can test your deploys. &lt;a href="https://github.com/ansistrano/deploy"&gt;Ansistrano&lt;/a&gt; is used for finally deploying our app to staging and production environments.&lt;/p&gt;

&lt;p&gt;Ansible Rails automates the following tasks -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installation of common packages&lt;/li&gt;
&lt;li&gt;Intall Ruby (via rbenv)&lt;/li&gt;
&lt;li&gt;Install Rails 6, Puma, Sidekiq&lt;/li&gt;
&lt;li&gt;SSH hardening&lt;/li&gt;
&lt;li&gt;Installing firewall (UFW)&lt;/li&gt;
&lt;li&gt;Redis&lt;/li&gt;
&lt;li&gt;Nodejs/Webpack/yarn&lt;/li&gt;
&lt;li&gt;Postgresql and another role that saves backups to S3&lt;/li&gt;
&lt;li&gt;Setup Nginx with some sensible config (thanks to nginxconfig.io)&lt;/li&gt;
&lt;li&gt;Install Certbot (for Letsencrypt SSL Certs)&lt;/li&gt;
&lt;li&gt;Deploying using Ansistrano&lt;/li&gt;
&lt;li&gt;Ansistrano 'hooks' are provided for performing the following tasks -

&lt;ul&gt;
&lt;li&gt;Installing all our gems&lt;/li&gt;
&lt;li&gt;Precompiling assets&lt;/li&gt;
&lt;li&gt;Migrating our database (using run_once)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find the detailed setup and usage guide/documentation here - &lt;a href="https://github.com/EmailThis/ansible-rails"&gt;https://github.com/EmailThis/ansible-rails&lt;/a&gt;. But the next section contains a primer that will help you get started quickly. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Side note&lt;/em&gt;: If you haven't used Ansible before, don't worry, it is really easy to understand and get started with it. Simply put, Ansible is an open-source server automation tool. It helps you set up your servers easily. There's no need for you to SSH into each server to do the grunt work (e.g: Updating packages, installing depedencies etc). You can write a simple YAML file containing a bunch of tasks and then tell Ansible to perform those tasks on your server(s). You can read more about it &lt;a href="https://www.ansible.com/"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step 1: Installation
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/EmailThis/ansible-rails ansible-rails
cd ansible-rails
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 2: Configuration
&lt;/h4&gt;

&lt;p&gt;Open &lt;code&gt;app-vars.yml&lt;/code&gt; and change the following variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app_name:           YOUR_APP_NAME   // Replace with name of your app
app_git_repo:       "YOUR_GIT_REPO" // e.g.: github.com/EmailThis/et
app_git_branch:     "master"        // branch that you want to deploy (e.g: 'production')

postgresql_db_user:     "{{ deploy_user }}_postgresql_user"
postgresql_db_password: "{{ vault_postgresql_db_password }}" # from vault (see next section)
postgresql_db_name:     "{{ app_name }}_production"

nginx_https_enabled: false # change to true if you wish to install SSL certificate 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 3: Deploy!
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vagrant up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you don't want to use Vagrant. Change the &lt;code&gt;inventories/development.ini&lt;/code&gt; file and then run the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible-playbook -i inventories/development.ini provision.yml
ansible-playbook -i inventories/development.ini deploy.yml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h3&gt;
  
  
  Documentation
&lt;/h3&gt;

&lt;p&gt;For more information and documentation, please refer to the Github repo - &lt;a href="https://github.com/EmailThis/ansible-rails"&gt;https://github.com/EmailThis/ansible-rails&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Questions, comments, suggestions?
&lt;/h3&gt;

&lt;p&gt;Please let me know if you run into any issues or if you have any questions. I'd be happy to help. I would also welcome any improvements/suggestions by way of pull requests.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Shameless plug&lt;/strong&gt; 🙈: Here's the &lt;a href="https://www.emailthis.me"&gt;app&lt;/a&gt; that I deployed using this tool. It is a &lt;a href="https://www.emailthis.me"&gt;simple bookmarking and 'read later' tool called EmailThis.me&lt;/a&gt; (think of it as a simpler alternative to Pocket that turns your email inbox into your reading list).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let me know what you guys think about it 🙌🏻&lt;/p&gt;

</description>
      <category>rails</category>
      <category>devops</category>
      <category>webdev</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
