-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adding ansible deployment mechanism
- Updating service script to start/stop sockify
- Loading branch information
Yauhen Yakimovich
committed
Aug 24, 2015
1 parent
9a0d239
commit 214cee0
Showing
17 changed files
with
367 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[defaults] | ||
hostfile = hosts | ||
roles_path = playbooks/roles | ||
executable = /bin/bash |
18 changes: 18 additions & 0 deletions
18
scripts/picostack-playbooks/playbooks/deploy-picostack.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Ansible-based provisioning script automating the deploy of the picostack | ||
# on the linux (Ubuntu) host. | ||
# | ||
# @author: Yauhen Yakimovich <eugeny.yakimovitch@gmail.com>, | ||
# | ||
# @license: The MIT License (MIT). Read a copy of LICENSE distributed with | ||
# this code. | ||
--- | ||
- name: Deploy picostack application | ||
hosts: targets | ||
# vars_files: | ||
# - roles/xxx/vars/xxx.yml | ||
vars: | ||
# overwrite roles/picostack_app/defaults/main.yml | ||
deploy_user: pstk | ||
app_domain: "{{ ansible_ssh_host }}" | ||
roles: | ||
- picostack_app |
38 changes: 38 additions & 0 deletions
38
scripts/picostack-playbooks/playbooks/roles/picostack_app/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Role Name | ||
========= | ||
|
||
A brief description of the role goes here. | ||
|
||
Requirements | ||
------------ | ||
|
||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. | ||
|
||
Dependencies | ||
------------ | ||
|
||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: | ||
|
||
- hosts: servers | ||
roles: | ||
- { role: username.rolename, x: 42 } | ||
|
||
License | ||
------- | ||
|
||
BSD | ||
|
||
Author Information | ||
------------------ | ||
|
||
An optional section for the role authors to include contact information, or a website (HTML is not allowed). |
11 changes: 11 additions & 0 deletions
11
scripts/picostack-playbooks/playbooks/roles/picostack_app/defaults/main.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# defaults file for picostack_app | ||
# turn off/on debug deploy | ||
# deploy_debug: yes | ||
# other vars | ||
deploy_user: pstk | ||
app_domain: picostack.mysite.org | ||
admin_email: admin@{{ app_domain }} | ||
app_dir: "/home/{{ deploy_user }}/picostack_app" | ||
django_dir: /usr/local/lib/python2.7/dist-packages/picostack | ||
django_wsgi_dir: "{{ django_dir }}/g0ph" |
3 changes: 3 additions & 0 deletions
3
scripts/picostack-playbooks/playbooks/roles/picostack_app/handlers/apache.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- name: restart apache2 | ||
service: name=apache2 state=restarted | ||
sudo: yes |
3 changes: 3 additions & 0 deletions
3
scripts/picostack-playbooks/playbooks/roles/picostack_app/handlers/main.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
# handlers file for picostack_app | ||
- include: apache.yml |
139 changes: 139 additions & 0 deletions
139
scripts/picostack-playbooks/playbooks/roles/picostack_app/meta/main.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
--- | ||
galaxy_info: | ||
author: your name | ||
description: | ||
company: your company (optional) | ||
# If the issue tracker for your role is not on github, uncomment the | ||
# next line and provide a value | ||
# issue_tracker_url: http://example.com/issue/tracker | ||
# Some suggested licenses: | ||
# - BSD (default) | ||
# - MIT | ||
# - GPLv2 | ||
# - GPLv3 | ||
# - Apache | ||
# - CC-BY | ||
license: license (GPLv2, CC-BY, etc) | ||
min_ansible_version: 1.2 | ||
# | ||
# Below are all platforms currently available. Just uncomment | ||
# the ones that apply to your role. If you don't see your | ||
# platform on this list, let us know and we'll get it added! | ||
# | ||
#platforms: | ||
#- name: EL | ||
# versions: | ||
# - all | ||
# - 5 | ||
# - 6 | ||
# - 7 | ||
#- name: GenericUNIX | ||
# versions: | ||
# - all | ||
# - any | ||
#- name: Fedora | ||
# versions: | ||
# - all | ||
# - 16 | ||
# - 17 | ||
# - 18 | ||
# - 19 | ||
# - 20 | ||
# - 21 | ||
# - 22 | ||
#- name: Windows | ||
# versions: | ||
# - all | ||
# - 2012R2 | ||
#- name: SmartOS | ||
# versions: | ||
# - all | ||
# - any | ||
#- name: opensuse | ||
# versions: | ||
# - all | ||
# - 12.1 | ||
# - 12.2 | ||
# - 12.3 | ||
# - 13.1 | ||
# - 13.2 | ||
#- name: Amazon | ||
# versions: | ||
# - all | ||
# - 2013.03 | ||
# - 2013.09 | ||
#- name: GenericBSD | ||
# versions: | ||
# - all | ||
# - any | ||
#- name: FreeBSD | ||
# versions: | ||
# - all | ||
# - 8.0 | ||
# - 8.1 | ||
# - 8.2 | ||
# - 8.3 | ||
# - 8.4 | ||
# - 9.0 | ||
# - 9.1 | ||
# - 9.1 | ||
# - 9.2 | ||
#- name: Ubuntu | ||
# versions: | ||
# - all | ||
# - lucid | ||
# - maverick | ||
# - natty | ||
# - oneiric | ||
# - precise | ||
# - quantal | ||
# - raring | ||
# - saucy | ||
# - trusty | ||
# - utopic | ||
# - vivid | ||
#- name: SLES | ||
# versions: | ||
# - all | ||
# - 10SP3 | ||
# - 10SP4 | ||
# - 11 | ||
# - 11SP1 | ||
# - 11SP2 | ||
# - 11SP3 | ||
#- name: GenericLinux | ||
# versions: | ||
# - all | ||
# - any | ||
#- name: Debian | ||
# versions: | ||
# - all | ||
# - etch | ||
# - jessie | ||
# - lenny | ||
# - squeeze | ||
# - wheezy | ||
# | ||
# Below are all categories currently available. Just as with | ||
# the platforms above, uncomment those that apply to your role. | ||
# | ||
#categories: | ||
#- cloud | ||
#- cloud:ec2 | ||
#- cloud:gce | ||
#- cloud:rax | ||
#- clustering | ||
#- database | ||
#- database:nosql | ||
#- database:sql | ||
#- development | ||
#- monitoring | ||
#- networking | ||
#- packaging | ||
#- system | ||
#- web | ||
dependencies: [] | ||
# List your role dependencies here, one per line. | ||
# Be sure to remove the '[]' above if you add dependencies | ||
# to this list. | ||
|
34 changes: 34 additions & 0 deletions
34
scripts/picostack-playbooks/playbooks/roles/picostack_app/tasks/apache.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
# Install Apache server | ||
|
||
- name: install apache2 | ||
sudo: yes | ||
apt: name=apache2 | ||
|
||
- name: install mod_wsgi | ||
sudo: yes | ||
apt: name=libapache2-mod-wsgi | ||
|
||
- name: enabled mod_wsgi | ||
sudo: yes | ||
apache2_module: name=wsgi state=present | ||
notify: | ||
- restart apache2 | ||
|
||
- name: enabled mod_rewrite | ||
sudo: yes | ||
apache2_module: name=rewrite state=present | ||
notify: | ||
- restart apache2 | ||
|
||
- name: create virtual host file | ||
sudo: yes | ||
template: src=../templates/virtualhost.j2 dest="/etc/apache2/sites-available/{{ app_domain }}.conf" | ||
|
||
- name: enable apache site | ||
sudo: yes | ||
command: a2ensite "{{ app_domain }}" | ||
args: | ||
creates: "/etc/apache2/sites-enabled/{{ app_domain }}" | ||
notify: | ||
- restart apache2 |
5 changes: 5 additions & 0 deletions
5
scripts/picostack-playbooks/playbooks/roles/picostack_app/tasks/main.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
# tasks file for picostack_app | ||
- include: apache.yml | ||
- include: python-django.yml | ||
- include: picostack-git.yml |
15 changes: 15 additions & 0 deletions
15
scripts/picostack-playbooks/playbooks/roles/picostack_app/tasks/picostack-git.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- name: Delete app folder if any | ||
file: path="{{ app_dir }}" state=absent | ||
|
||
- name: Get the latest code from github | ||
git: repo="https://github.com/ewiger/picostack.git" | ||
dest="{{ app_dir }}" | ||
accept_hostkey=yes | ||
update=yes | ||
clone=yes | ||
force=yes | ||
|
||
- name: Install app in dev mode | ||
shell: "sudo pip install -e ." | ||
args: | ||
chdir: "{{ app_dir }}" |
37 changes: 37 additions & 0 deletions
37
scripts/picostack-playbooks/playbooks/roles/picostack_app/tasks/python-django.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Update packages every hour | ||
- name: Update all packages to the latest version | ||
sudo: yes | ||
tags: | ||
- update | ||
apt: upgrade=safe update_cache=yes cache_valid_time=3600 | ||
|
||
- name: Install apt packages | ||
sudo: yes | ||
apt: | ||
name: "{{ item }}" | ||
state: installed | ||
with_items: | ||
- git | ||
- python-setuptools | ||
- python-dev | ||
- build-essential | ||
- libmysqlclient-dev | ||
tags: | ||
- python | ||
- django | ||
|
||
- name: Install pip packages | ||
sudo: yes | ||
pip: | ||
name: "{{ item }}" | ||
state: present | ||
with_items: | ||
- MySQL-python | ||
- simplejson | ||
- django | ||
- django-nose | ||
#- django-registration-redux | ||
#- djangorestframework | ||
tags: | ||
- python | ||
- django |
39 changes: 39 additions & 0 deletions
39
scripts/picostack-playbooks/playbooks/roles/picostack_app/templates/virtualhost.j2
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# picostack virtual host: | ||
<VirtualHost *:80> | ||
ServerAdmin {{ admin_email }} | ||
DocumentRoot {{ django_wsgi_dir }} | ||
ServerName {{ app_domain }} | ||
ErrorLog ${APACHE_LOG_DIR}/picostack.error.log | ||
CustomLog ${APACHE_LOG_DIR}/picostack.access.log combined | ||
|
||
WSGIScriptAlias / {{ django_wsgi_dir }}/wsgi.py | ||
WSGIDaemonProcess {{ app_domain }} python-path={{ django_dir }}:/usr/lib/python2.7/dist-packages/:/usr/local/lib/python2.7/dist-packages | ||
WSGIProcessGroup picostack.mysite.org | ||
|
||
<Directory "{{ django_wsgi_dir }}"> | ||
<Files wsgi.py> | ||
Require all granted | ||
# For apache <= 2.4 uncomment and use lines below instead | ||
# Order allow,deny | ||
# Allow from all | ||
</Files> | ||
</Directory> | ||
|
||
Alias /static/admin/ /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/ | ||
|
||
<Directory "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/"> | ||
Require all granted | ||
# For apache <= 2.4 uncomment and use lines below instead | ||
# Order allow,deny | ||
# Allow from all | ||
</Directory> | ||
|
||
Alias /static/ {{ django_wsgi_dir }}/static/ | ||
|
||
<Directory "{{ django_wsgi_dir }}/static/"> | ||
Require all granted | ||
# For apache <= 2.4 uncomment and use lines below instead | ||
# Order allow,deny | ||
# Allow from all | ||
</Directory> | ||
</VirtualHost> |
Oops, something went wrong.