Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiguelv committed Jun 9, 2016
0 parents commit 1748749
Show file tree
Hide file tree
Showing 46 changed files with 2,083 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "assets/vendor"
}
65 changes: 65 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Local
.DS_Store
.babelrc
.tox/
.vagrant/
local.py
logs/
static/
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python

python:
- 2.7

install:
- pip install tox-travis

script:
- tox
22 changes: 22 additions & 0 deletions .vagrant_provisioning/local_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import getpass

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'kdl',
'USER': 'kdl',
'PASSWORD': 'kdl',
'ADMINUSER': 'postgres',
'HOST': 'localhost'
},
}

INTERNAL_IPS = ('0.0.0.0', '127.0.0.1', '::1')

SECRET_KEY = '12345'

FABRIC_USER = getpass.getuser()

CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False
SESSION_COOKIE_SECURE = False
287 changes: 287 additions & 0 deletions .vagrant_provisioning/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
---
- hosts: all
vars_files:
- vars.yml
gather_facts: false
become: true

tasks:
- name: fix debian sudoers file
become: yes
lineinfile:
dest: /etc/sudoers
backup: yes
regexp: "^%sudo\\s+ALL=\\(ALL:ALL\\)\\s+ALL$"
line: "%sudo ALL=(ALL) NOPASSWD: ALL"
tags:
- system

- name: apt | add wheezy backports
apt_repository:
repo: deb http://http.debian.net/debian wheezy-backports main
state: present
tags:
- system

- name: apt | install https transport for apt
apt:
pkg: apt-transport-https
state: installed
# update_cache: yes
tags:
-system

- name: apt | add node key
become: yes
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present
tags:
- system

- name: apt | add nodejs sources
apt_repository:
repo: 'deb https://deb.nodesource.com/node wheezy main'
state: present
tags:
- system

- name: apt | add nodejs sourcecode sources
apt_repository:
repo: 'deb-src https://deb.nodesource.com/node wheezy main'
state: present
tags:
- system

- name: apt | add elasticsearch key
become: yes
apt_key:
url: https://packages.elastic.co/GPG-KEY-elasticsearch
state: present
tags:
- system

- name: apt | add elasticsearch sources
apt_repository:
repo: 'deb http://packages.elastic.co/elasticsearch/1.6/debian stable main'
state: present
tags:
- system

- name: apt | install required system packages
apt:
pkg: '{{ item }}'
state: installed
update_cache: yes
with_items: '{{ system_packages }}'
tags:
- system

- name: zsh | clone oh-my-zsh repo
git: repo={{ zsh.oh_my_zsh }} dest={{ user_home }}/.oh-my-zsh
tags:
- system

- name: zsh | deploy .zshrc
copy: src={{ zsh.zshrc }} dest={{ user_home }}/.zshrc owner=vagrant
tags:
- system

- name: zsh | as default shell
user: name=vagrant shell=/bin/zsh
tags:
- system

- hosts: all
vars_files:
- vars.yml
gather_facts: false
tasks:
- name: pip | setup virtualenv
command: mkdir -p {{ python.virtualenv_location }}
- command: virtualenv {{ python.virtualenv_location }}
tags:
- python

- name: pip | update setuptools
pip:
name: setuptools
virtualenv: "{{ python.virtualenv_location }}"
state: latest
tags:
- python

- name: pip | update pip
pip:
name: pip
virtualenv: "{{ python.virtualenv_location }}"
state: latest
tags:
- python

- name: pip | ensure python requirements are installed to latest version
pip:
requirements: "{{ project_root }}/{{ python.requirements }}"
virtualenv: "{{ python.virtualenv_location }}"
tags:
- python

- hosts: all
vars_files:
- vars.yml
# gather_facts: false
tasks:
- name: locale | setup gb locale
locale_gen:
name: "{{ postgresql.locale }}"
state: present
become: yes
tags:
- db

- name: postgresql | ensure postgresql user can authenticate
become: yes
lineinfile:
dest: /etc/postgresql/{{ postgresql.version }}/main/pg_hba.conf
backup: yes
regexp: "^local\\s+all\\s+{{ postgresql.admin_user }}\\s+peer$"
line: "local all {{ postgresql.admin_user }} {{ postgresql.default_auth_method }}"
tags:
- db

- name: postgresql | ensure all users can authenticate
become: yes
lineinfile:
dest: /etc/postgresql/{{ postgresql.version }}/main/pg_hba.conf
backup: yes
regexp: "^local\\s+all\\s+all\\s+peer$"
line: "local all all {{ postgresql.default_auth_method }}"
notify:
- postgresql | restart postgres
- elasticsearch | restart elasticsearch
tags:
- db

handlers:
- name: postgresql | restart postgres
become: yes
service:
name: postgresql
state: restarted
tags:
- db

- name: elasticsearch | restart elasticsearch
become: yes
service:
name: elasticsearch
state: started
tags:
- db

- hosts: all
vars_files:
- vars.yml
tasks:
- name: postgresql | create user
become_user: "{{ postgresql.admin_user }}"
postgresql_user:
user: "{{ postgresql.user }}"
password: "{{ app.name }}"
role_attr_flags: CREATEDB # NOSUPERUSER NOCREATEROLE
tags:
- db

- name: postgresql | create db
become_user: "{{ postgresql.admin_user }}"
postgresql_db:
name: "{{ app.name }}"
encoding: "{{postgresql.encoding}}"
lc_collate: "{{postgresql.locale}}"
lc_ctype: "{{postgresql.locale}}"
template: "template0"
state: present
owner: "{{ postgresql.user }}"
notify:
- postgresql | apply privileges
tags:
- db

- name: check if initial data file exists
stat:
path: "{{ project_root }}/.vagrant_provisioning/{{ postgresql.initial_data_file }}"
register: idf
tags:
- db
- data

- name: posgresql | load initial data file
command: psql -U {{ postgresql.user }} -d {{ app.name }} -f {{ project_root }}/.vagrant_provisioning/{{ postgresql.initial_data_file }}
when: idf.stat.exists
notify:
- postgresql | apply privileges after data import
tags:
- db
- data

handlers:
- name: postgresql | apply privileges
become_user: "{{ postgresql.admin_user }}"
postgresql_privs:
db: "{{ app.name }}"
privs: ALL
roles: "{{ postgresql.user }}"
state: present
type: database
tags:
- db
- data

- name: postgresql | apply privileges after data import
become_user: "{{ postgresql.admin_user }}"
postgresql_privs:
db: "{{ app.name }}"
objs: ALL_IN_SCHEMA
privs: ALL
roles: "{{ postgresql.user }}"
state: present
type: table
tags:
- db
- data

- hosts: all
vars_files:
- vars.yml
tasks:
- name: django | default local settings
copy: src=local_settings.py dest={{ project_root }}/{{ app.name }}/settings/local.py owner=vagrant
tags:
- django

- name: django | migrations
command: "{{ user_home }}/venv/bin/python {{ project_root }}/manage.py makemigrations"
- command: "{{ user_home }}/venv/bin/python {{ project_root }}/manage.py migrate"
tags:
- django

- hosts: all
vars_files:
- vars.yml
tasks:
- name: git | init
command: "git init"
args:
chdir: "{{ project_root }}"
tags:
- git

- name: git | flake8 pre-commit hook
command: "{{ user_home }}/venv/bin/flake8 --install-hook"
args:
chdir: "{{ project_root }}"
- command: "git config flake8.strict True"
args:
chdir: "{{ project_root }}"
tags:
- git
Loading

0 comments on commit 1748749

Please sign in to comment.