From a963204a2b5c0782faa3ef2e3acd60f2a4a0a2b4 Mon Sep 17 00:00:00 2001 From: Rob Cameron Date: Tue, 7 Apr 2015 15:20:55 -0700 Subject: [PATCH] completed reggie deploy --- proctor/ansible/inventory.yml | 2 +- proctor/ansible/playbooks/deploy_reggie.yml | 63 ++++++++++++++----- .../ansible/playbooks/files/.python-version | 1 + proctor/ansible/playbooks/files/nginx.conf | 0 proctor/ansible/playbooks/files/reggie.conf | 24 +++++++ .../ansible/playbooks/files/reggie_default | 34 ++++++++++ 6 files changed, 107 insertions(+), 17 deletions(-) create mode 100644 proctor/ansible/playbooks/files/.python-version delete mode 100644 proctor/ansible/playbooks/files/nginx.conf create mode 100644 proctor/ansible/playbooks/files/reggie.conf create mode 100644 proctor/ansible/playbooks/files/reggie_default diff --git a/proctor/ansible/inventory.yml b/proctor/ansible/inventory.yml index 83f9123..32eb7ea 100644 --- a/proctor/ansible/inventory.yml +++ b/proctor/ansible/inventory.yml @@ -3,7 +3,7 @@ [public_server] -10.10.0.10 ansible_python_interpreter=python +10.10.0.10 [private_server] diff --git a/proctor/ansible/playbooks/deploy_reggie.yml b/proctor/ansible/playbooks/deploy_reggie.yml index fd77261..5627c82 100644 --- a/proctor/ansible/playbooks/deploy_reggie.yml +++ b/proctor/ansible/playbooks/deploy_reggie.yml @@ -4,7 +4,6 @@ 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" @@ -12,13 +11,17 @@ 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 @@ -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 diff --git a/proctor/ansible/playbooks/files/.python-version b/proctor/ansible/playbooks/files/.python-version new file mode 100644 index 0000000..bec3a35 --- /dev/null +++ b/proctor/ansible/playbooks/files/.python-version @@ -0,0 +1 @@ +system diff --git a/proctor/ansible/playbooks/files/nginx.conf b/proctor/ansible/playbooks/files/nginx.conf deleted file mode 100644 index e69de29..0000000 diff --git a/proctor/ansible/playbooks/files/reggie.conf b/proctor/ansible/playbooks/files/reggie.conf new file mode 100644 index 0000000..f7dea55 --- /dev/null +++ b/proctor/ansible/playbooks/files/reggie.conf @@ -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 diff --git a/proctor/ansible/playbooks/files/reggie_default b/proctor/ansible/playbooks/files/reggie_default new file mode 100644 index 0000000..065a06e --- /dev/null +++ b/proctor/ansible/playbooks/files/reggie_default @@ -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; + } +}