Commit 41486d4c by Jocelyn Delalande
parent f6c041d6
transparency_user: transparency
transparency_group: transparency
transparency_home_dir: /srv/transparency
transparency_git_repo_url: https://code.ffdn.org/jocelyn/transparency.git
transparency_version: master
transparency_site_name: 'Transparency'
transparency_install_dir: '{{ transparency_home_dir }}/app'
transparency_media_dir: '{{ transparency_install_dir }}/site_media'
transparency_static_dir: '{{ transparency_home_dir }}/static'
transparency_gunicorn_port: 8082
transparency_venv_dir: '{{ transparency_home_dir }}/venv'
transparency_venv_bin_path: "{{ transparency_venv_dir }}/bin"
transparency_admins: []
\ No newline at end of file
- name: restart transparency
supervisorctl: name=transparency state=restarted
- name: restart supervisor
service: name=supervisor state=restarted
- name: install dependencies
apt: name={{ item }} force=yes state=present
with_items:
- python
- python-virtualenv
- python-all-dev
- python-pip
- git
- supervisor
- sudo
- name: create Transparency user
user: name={{ transparency_user }} home={{ transparency_home_dir }}
- name: fetch application sources
become: yes
git:
repo: '{{ transparency_git_repo_url }}'
dest: '{{ transparency_install_dir }}'
accept_hostkey: yes
version: '{{ transparency_version }}'
notify: restart transparency
- name: Attribute source to transparency user
file:
path: '{{ transparency_install_dir }}'
state: directory
owner: '{{ transparency_user }}'
group: '{{ transparency_user }}'
recurse: yes
- name: create virtualenv
become: yes
become_user: '{{ transparency_user }}'
shell: virtualenv {{ transparency_venv_dir }} --python=/usr/bin/python3 creates={{ transparency_venv_dir }}
- name: install pip requirements
become: yes
become_user: '{{ transparency_user }}'
pip:
requirements: '{{ transparency_install_dir }}/requirements.txt'
virtualenv: '{{ transparency_venv_dir }}'
- name: install gunicorn
become: yes
become_user: '{{ transparency_user }}'
pip: name=gunicorn virtualenv={{ transparency_venv_dir }}
- name: set local_settings.py
become_user: '{{ transparency_user }}'
template:
src: local_settings.j2
dest: "{{ transparency_install_dir }}/transparency/local_settings.py"
owner: '{{ transparency_user }}'
notify: restart transparency
- name: migrate db
become: yes
become_user: '{{ transparency_user }}'
shell: ./manage.py migrate --noinput
args:
chdir: '{{ transparency_install_dir }}'
environment:
PATH: '{{ transparency_venv_bin_path }}:{{ ansible_env.PATH }}'
DJANGO_SETTINGS_FILE: '{{ transparency_install_dir }}/settings.py'
- name: create static dir
file:
path: '{{ transparency_static_dir }}'
state: directory
owner: '{{ transparency_user }}'
group: '{{ transparency_user }}'
recurse: yes
- name: collect static files
become: yes
become_user: '{{ transparency_user }}'
shell: './manage.py collectstatic --noinput'
args:
chdir: '{{ transparency_install_dir }}'
environment:
PATH: "{{ transparency_venv_bin_path }}:{{ ansible_env.PATH }}"
- name: install supervisor
apt: pkg=supervisor state=present
- name: set supervisord config
template: src=supervisor.j2 dest=/etc/supervisor/conf.d/transparency.conf mode=644
notify: restart supervisor
- name: ensure application is running
supervisorctl: name=transparency state=started
# -*- coding: utf-8 -*-
# Django settings for project.
SECRET_KEY = '{{ transparency_secret_key }}'
SITE_ID = 1
SITE_URL = '{{ transparency_url }}'
SITE_NAME = '{{ transparency_site_name }}'
ADMINS = [{% for i in transparency_admins %}('{{ i.name }}', '{{ i.mail }}') {% endfor %}]
ALLOWED_HOSTS = ['{{ transparency_domain }}']
# Where static files gets collected
STATIC_ROOT = '{{ transparency_static_dir }}'
ORGANIZATION_NAME = '{{ transparency_organization_name }}'
[program:transparency]
environment=DJANGO_SETTINGS_MODULE='transparency.settings'
directory={{ transparency_install_dir }}
command={{ transparency_venv_bin_path }}/gunicorn -b 127.0.0.1:{{ transparency_gunicorn_port }} transparency.wsgi:application
user={{ transparency_user }}
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/transparency.log
redirect_stderr=true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment