Skip to content

Commit

Permalink
initial setup of ats
Browse files Browse the repository at this point in the history
more to do per #3
  • Loading branch information
Bridget Almas committed Aug 10, 2018
1 parent 235f960 commit aeed7eb
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data/nodes/ats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
classes:
- role::ats
21 changes: 21 additions & 0 deletions site-modules/profile/files/ats/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
certifi==2018.1.18
chardet==3.0.4
click==6.7
dateparser==0.7.0
Flask==0.12.2
Flask-SQLAlchemy==2.3.2
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
python-dateutil==2.7.1
pytz==2018.3
regex==2018.2.21
requests==2.18.4
six==1.11.0
SQLAlchemy==1.2.5
tzlocal==1.5.1
urllib3==1.22
Werkzeug==0.14.1
flask-cors==3.0.3
gunicorn==19.4.5
99 changes: 99 additions & 0 deletions site-modules/profile/manifests/ats.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
class profile::ats {
include profile::ssl
include profile::python3

$app_root = '/usr/local/alpheios-translation-service'
$repos = 'https://github.com/alpheios-project/alpheios-translation-service'

vcsrepo { $app_root:
ensure => latest,
revision => 'master',
provider => git,
source => $repos,
notify => Python::Virtualenv[$app_root],
}

file { "/etc/gunicorn.d":
ensure => directory,
}

file { "${app_root}/requirements.txt":
ensure => file,
source => 'puppet:///modules/profile/ats/requirements.txt',
require => Vcsrepo[$app_root],
notify => Python::Virtualenv[$app_root],
}


file { "${app_root}/app.py":
ensure => file,
content => epp('profile/ats/app.py.epp', {
}),
require => Vcsrepo[$app_root],
notify => Python::Virtualenv[$app_root],
}

python::virtualenv { $app_root:
ensure => present,
version => '3',
requirements => "${app_root}/requirements.txt",
venv_dir => "${app_root}/venv",
cwd => $app_root,
notify => Exec['restart-ats-gunicorn'],
require => File['/etc/gunicorn.d'],
}

python::gunicorn { 'ats-vhost':
ensure => present,
virtualenv => "${app_root}/venv",
dir => $app_root,
timeout => 120,
bind => 'localhost:5000',
appmodule => 'app:app',
owner => 'www-data',
group => 'www-data',
}

exec { 'restart-ats-gunicorn':
command => '/usr/sbin/service gunicorn restart',
refreshonly => true,
require => Python::Gunicorn['ats-vhost'],
}

$proxy_pass = {
'path' => '/',
'url' => 'http://localhost:5000/',
}

$headers = [
"set Access-Control-Allow-Origin '*'",
"set Access-Control-Allow-Methods 'GET, POST, OPTIONS'"
]

apache::vhost { 'ats':
servername => 'ats.alpheios.net',
port => '80',
docroot => '/var/www/vhost',
proxy_pass => [ $proxy_pass ],
headers => $headers,
}

apache::vhost { 'ats-ssl':
servername => 'ats.alpheios.net',
port => '443',
docroot => '/var/www/vhost',
proxy_pass => [ $proxy_pass ],
headers => $headers,
ssl => true,
ssl_cert => '/etc/ssl/certs/STAR_alpheios.net.crt',
ssl_key => '/etc/ssl/private/Alpheios.key',
ssl_chain => '/etc/ssl/certs/ca-bundle-client.crt',
}

firewall { '100 ATS Service Access':
proto => 'tcp',
dport => ['80','443'],
action => 'accept',
}

}
6 changes: 6 additions & 0 deletions site-modules/profile/templates/ats/app.py.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python
from flask import Flask
from atservices import create_app

app,db = create_app()

4 changes: 4 additions & 0 deletions site-modules/role/manifests/ats.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class role::ats {
include profile::common
include profile::ats
}

0 comments on commit aeed7eb

Please sign in to comment.