Skip to content

Instantly share code, notes, and snippets.

@rstarmer
Created December 29, 2015 10:16
Show Gist options
  • Select an option

  • Save rstarmer/355ccdbb8c493b458bde to your computer and use it in GitHub Desktop.

Select an option

Save rstarmer/355ccdbb8c493b458bde to your computer and use it in GitHub Desktop.
Main playbook for simple ruby application deployment. Requires 'passenger' role as well.
---
- hosts: all
sudo: yes
roles:
- passenger
handlers:
- name: reload apache
service: name=httpd state=reloaded
pre_tasks:
- name: create user
user: name=web shell=/bin/bash groups=wheel createhome=yes state=present append=yes
- name: install git
yum: name=git state=present
- name: ruby
yum: name=ruby-devel state=present
- name: rubygems
yum: name=rubygems state=present
- name: install bundler gem
gem: name=bundler state=present
- name: install apache
yum: name=httpd state=present
tasks:
- name: add firewalld
yum: name=firewalld state=present
- name: start the firewalld services
service: name=firewalld state=started
- name: Add http access
command: firewall-cmd --zone=public --add-service=http
- name: Copy across new virtual host
template:
src=templates/ruby_hw.conf.j2
dest=/etc/httpd/conf.d/ruby_hw.conf
notify:
- reload apache
- name: Add ServerAlias to ruby_hw.conf
lineinfile: dest=/etc/httpd/conf.d/ruby_hw.conf insertafter="ServerName" line=" ServerAlias {{ansible_default_ipv4.address}}"
notify:
- reload apache
- name: Get project from git
git: clone=yes dest=/var/www/ruby_hw repo=https://github.com/rstarmer/ruby_hw remote=develop
- name: change directory ownership
file: owner=web recurse=yes path=/var/www/ruby_hw
notify:
- reload apache
- name: Install bundler package
yum: name=rubygem-bundler state=present
# requires ansible > 2.1
# - name: bundle install the required gem files
# bundler: chdir=/var/www/ruby_hw state=present executable=/usr/local/bin/bundle deployment=yes
- name: Install via bundler
command: bundle install --deployment --without development test
chdir=/var/www/ruby_hw
become_user: web
notify:
- reload apache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment