Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
completed reggie deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
RobWC committed Apr 7, 2015
1 parent c9e2971 commit a963204
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 17 deletions.
2 changes: 1 addition & 1 deletion proctor/ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


[public_server]
10.10.0.10 ansible_python_interpreter=python
10.10.0.10


[private_server]
Expand Down
63 changes: 47 additions & 16 deletions proctor/ansible/playbooks/deploy_reggie.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
connection: local
gather_facts: no
vars:
# reggie_repo_url: "https://github.com/JNPRAutomate/reggie/archive/master.zip"
reggie_repo_url: "https://github.com/JNPRAutomate/reggie.git"
reggie_zip: "reggie.zip"
reggie_app_root: "/reggie"
reggie_user: "vagrant"
reggie_group: "vagrant"

tasks:
- name: Install Python APT
sudo: yes
shell: sudo apt-get install python-apt -y

- name: Install NGINX
sudo: yes
apt: name=nginx state=latest update_cache=yes

- name: Install PIP
sudo: yes
apt: name=python-pip state=latest update_cache=yes
apt: name=python-pip state=latest update_cache=no

- name: creates reggie root directory
sudo: yes
Expand All @@ -34,19 +37,47 @@
repo="{{ reggie_repo_url }}"
dest="{{ reggie_app_root }}"

- name: Configure Python
shell: echo “system” > {{ reggie_app_root }}/.python-version

# - name: create pyenv environment
# pyenv_path: "/home/{{ reggie_user }}/.pyenv"
# pyenv_owner: "{{ reggie_user }}"
# pyenv_python_versions:
# - "3.4.1"
# - "2.7.8"
# pyenv_virtualenvs:
# - venv_name: "reggie_env"
# py_version: "2.7.8"
- name: Configure System Python for Reggie
copy: src=files/.python-version dest={{ reggie_app_root }} owner=vagrant group=vagrant

- name: install reggie pip requirements
pip:
requirements="{{ reggie_app_root }}/requirements.txt"
sudo: yes
pip: requirements="{{ reggie_app_root }}/requirements.txt" chdir={{ reggie_app_root }} executable=/usr/bin/pip

- name: Create vSRX License Root Directory
sudo: yes
file:
path=/vsrx_license
state=directory
owner=www-data
group=www-data
mode=0775

- name: Create vSRX License Directory
sudo: yes
file:
path=/vsrx_license/license
state=directory
owner=www-data
group=www-data
mode=0775

- name: Copy NGINX Config
sudo: yes
copy: src=files/reggie_default dest=/etc/nginx/sites-enabled owner=root group=root

- name: Remove NGINX Default Config
sudo: yes
file: path=/etc/nginx/sites-enabled/default state=absent

- name: Install Reggie as Upstart service
sudo: yes
copy: src=files/reggie.conf dest=/etc/init/reggie.conf owner=root group=root

- name: Start Reggie service
sudo: yes
service: name=reggie state=started

- name: Restart NGINX service
sudo: yes
service: name=nginx state=restarted sleep=5
1 change: 1 addition & 0 deletions proctor/ansible/playbooks/files/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
system
Empty file.
24 changes: 24 additions & 0 deletions proctor/ansible/playbooks/files/reggie.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
description "Reggie Registration portal"
author "Rob Cameron"
console log

# used to be: start on startup
# until we found some mounts weren't ready yet while booting:
start on started networking
stop on shutdown

# Automatically Respawn:
respawn
respawn limit 99 5

script
# Not sure why $HOME is needed, but we found that it is:
export HOME="/reggie"

exec start-stop-daemon --start -d /reggie -c vagrant --exec /usr/bin/python app.py runserver
end script

post-start script
# Optionally put a script here that will notifiy you node has (re)started
# /root/bin/hoptoad.sh "node.js has started!"
end script
34 changes: 34 additions & 0 deletions proctor/ansible/playbooks/files/reggie_default
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
listen 80 default_server;
listen [::]:80 default_server;

# Make site accessible from http://localhost/
server_name localhost;

location /license {
root /vsrx_license;
}

location / {
proxy_pass http://127.0.0.1:5000;
}
}

0 comments on commit a963204

Please sign in to comment.