Commit 5b4d3323 by Joe Blaylock

Configurable app base directory

* Replace hardcoded instances of /opt/wwc with $app_base_dir, which
  defaults to /opt/wwc.
* Add tags to nginx tasks so they can be selected independently.
parent 9d13f136
---
app_base_dir: /opt/wwc
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- include: create_users.yml - include: create_users.yml
- name: Create application root - name: Create application root
sudo: True sudo: True
file: path=/opt/wwc state=directory owner=root group=root file: path=$app_base_dir state=directory owner=root group=root
- name: Create log directory - name: Create log directory
sudo: True sudo: True
file: path=/mnt/logs state=directory file: path=/mnt/logs state=directory
......
...@@ -9,8 +9,8 @@ nginx_cfg: ...@@ -9,8 +9,8 @@ nginx_cfg:
edx_release: link edx_release: link
# path to version files for the basic # path to version files for the basic
# nginx configuration # nginx configuration
version_html: /opt/wwc/versions.html version_html: $app_base_dir/versions.html
version_json: /opt/wwc/versions.json version_json: $app_base_dir/versions.json
# default htpasswd contents set to edx/edx # default htpasswd contents set to edx/edx
# this value can be overiden in vars/secure/<group>.yml # this value can be overiden in vars/secure/<group>.yml
htpasswd: | htpasswd: |
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
# - nginx/tasks/main.yml # - nginx/tasks/main.yml
--- ---
- name: create lms application config - name: create lms application config
template: src=env.json.j2 dest=/opt/wwc/lms.env.json template: src=env.json.j2 dest=$app_base_dir/lms.env.json
sudo: True sudo: True
- name: create lms auth file - name: create lms auth file
template: src=auth.json.j2 dest=/opt/wwc/lms.auth.json template: src=auth.json.j2 dest=$app_base_dir/lms.auth.json
sudo: True sudo: True
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
- name: install read-only ssh key for mitx repo (host github known) - name: install read-only ssh key for mitx repo (host github known)
copy: src=vars/secure/ssh_deploy_known_hosts dest=/home/ubuntu/.ssh/known_hosts force=yes owner=ubuntu group=ubuntu mode=600 copy: src=vars/secure/ssh_deploy_known_hosts dest=/home/ubuntu/.ssh/known_hosts force=yes owner=ubuntu group=ubuntu mode=600
# Check out mitx repo to /opt/wwc # Check out mitx repo to $app_base_dir
- name: set permissions on /opt/wwc sgid for edx - name: set permissions on $app_base_dir sgid for edx
file: path=/opt/wwc owner=root group=edx mode=2775 state=directory file: path=$app_base_dir owner=root group=edx mode=2775 state=directory
file: path=/opt/wwc/mitx owner=ubuntu group=edx mode=2775 state=directory file: path=$app_base_dir owner=ubuntu group=edx mode=2775 state=directory
sudo: True sudo: True
- name: install git and its recommends - name: install git and its recommends
apt: pkg=git state=installed install_recommends=yes apt: pkg=git state=installed install_recommends=yes
sudo: True sudo: True
- name: git checkout mitx repo into /opt/wwc - name: git checkout mitx repo into $app_base_dir
git: dest=/opt/wwc/mitx repo=git@github.com:MITx/mitx.git git: dest=$app_base_dir/mitx repo=git@github.com:MITx/mitx.git
...@@ -5,11 +5,15 @@ ...@@ -5,11 +5,15 @@
sudo: True sudo: True
apt: pkg=nginx state={{ pkgs.nginx.state }} apt: pkg=nginx state={{ pkgs.nginx.state }}
notify: restart nginx notify: restart nginx
tags:
- nginx
# removing default link # removing default link
- name: Removing default nginx config - name: Removing default nginx config
sudo: True sudo: True
file: path=/etc/nginx/sites-available/default state=absent file: path=/etc/nginx/sites-available/default state=absent
notify: restart nginx notify: restart nginx
tags:
- nginx
# Standard configuration that is common across all roles # Standard configuration that is common across all roles
# Default values for these variables are set in group_vars/all # Default values for these variables are set in group_vars/all
# Note: remove spaces in {{..}}, otherwise you will get a template parsing error. # Note: remove spaces in {{..}}, otherwise you will get a template parsing error.
...@@ -18,6 +22,10 @@ ...@@ -18,6 +22,10 @@
# Default htpassword file, required for basic auth # Default htpassword file, required for basic auth
- copy: content={{ nginx_cfg.htpasswd }} dest=/etc/nginx/nginx.htpasswd - copy: content={{ nginx_cfg.htpasswd }} dest=/etc/nginx/nginx.htpasswd
sudo: True sudo: True
tags:
- nginx
- name: Ensuring that nginx is running - name: Ensuring that nginx is running
sudo: True sudo: True
service: name=nginx state=started service: name=nginx state=started
tags:
- nginx
...@@ -4,8 +4,12 @@ ...@@ -4,8 +4,12 @@
sudo: True sudo: True
template: src={{ site_name }}.j2 dest=/etc/nginx/sites-available/{{ site_name }} template: src={{ site_name }}.j2 dest=/etc/nginx/sites-available/{{ site_name }}
notify: restart nginx notify: restart nginx
tags:
- nginx
- name: Creating nginx config link {{ site_name }} - name: Creating nginx config link {{ site_name }}
sudo: True sudo: True
file: src=/etc/nginx/sites-available/{{ site_name }} dest=/etc/nginx/sites-enabled/{{ site_name }} state={{ state }} owner=root group=root file: src=/etc/nginx/sites-available/{{ site_name }} dest=/etc/nginx/sites-enabled/{{ site_name }} state={{ state }} owner=root group=root
notify: restart nginx notify: restart nginx
tags:
- nginx
...@@ -3,7 +3,7 @@ server { ...@@ -3,7 +3,7 @@ server {
location / { location / {
auth_basic "Restricted"; auth_basic "Restricted";
auth_basic_user_file /etc/nginx/nginx.htpasswd; auth_basic_user_file /etc/nginx/nginx.htpasswd;
root /opt/wwc/main_static; root {{app_base_dir}}/main_static;
index index.html index index.html
proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Proto https;
} }
......
server { server {
# LMS configuration file for nginx, templated by ansible
listen 80; listen 80;
...@@ -65,7 +66,7 @@ server { ...@@ -65,7 +66,7 @@ server {
location ~ /static/(?P<file>.*) { location ~ /static/(?P<file>.*) {
auth_basic "Restricted"; auth_basic "Restricted";
auth_basic_user_file /etc/nginx/lms.htpasswd; auth_basic_user_file /etc/nginx/lms.htpasswd;
root /opt/wwc; root {{app_base_dir}};
try_files /staticfiles/$file /course_static/$file =404; try_files /staticfiles/$file /course_static/$file =404;
# return a 403 for static files that shouldn't be # return a 403 for static files that shouldn't be
......
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