Skip to content

Commit

Permalink
add demo playbooks and a README
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrec1 committed May 11, 2015
1 parent 5f71e4a commit 5b82e8e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
@@ -0,0 +1,11 @@
Use this repository as a bootstrap for your organization custom Ansible project.

In case you're new to Ansible, I added some demo playbooks to understand how you should do things. You should configure your inventory and then run the playbooks like this:

```
ansible-playbook -i inventory/production/demo provision_demo.yml
```

The content of this project was created following the Ansible best practices:

https://docs.ansible.com/playbooks_best_practices.html#content-organization
23 changes: 23 additions & 0 deletions deploy_demo.yml
@@ -0,0 +1,23 @@
---
- hosts: web
vars:
ansible_ssh_user: "{{ user }}"
tasks:
- name: update project source
git: repo={{repository}} dest={{app_path}} accept_hostkey=yes

- name: install gems with bundler
command: bundle install --deployment chdir={{ app_path }}

- name: migrate the database
command: bundle exec rake db:migrate RAILS_ENV={{ rails_env }} chdir={{ app_path }}

- name: compile assets
command: bundle exec rake assets:precompile RAILS_ENV={{ rails_env }} chdir={{ app_path }}

- name: registers puma pid
command: cat tmp/pids/puma.pid chdir={{ app_path }}
register: puma_pid

- name: restart puma
command: kill -USR2 {{ puma_pid.stdout }}
18 changes: 18 additions & 0 deletions inventory/production/demo
@@ -0,0 +1,18 @@
web1 ansible_ssh_host=<host or ip>
web2 ansible_ssh_host=<host or ip>

[web]
web1
web2

[database]
db1

[web:vars]
repository=<git repository url>
ansible_ssh_private_key_file=~/.ssh/demo_private_key
ansible_ssh_user=ubuntu
app_name=demo
app_path=/var/local/apps/demo
rails_env=production
user=deploy
17 changes: 17 additions & 0 deletions provision_demo.yml
@@ -0,0 +1,17 @@
---
- hosts: database
sudo: true
roles:
- postgresql-server

- hosts: web
sudo: true
vars:
ruby_version: 2.2.2
roles:
- git
- postgresql-client
- phantomjs
- nginx
- rails
- puma

0 comments on commit 5b82e8e

Please sign in to comment.