Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Xenial #1117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@
Vagrant.require_version ">= 2.0"
require "yaml"

CAC_SHARED_FOLDER_TYPE = ENV.fetch("CAC_SHARED_FOLDER_TYPE", "nfs")
CAC_NFS_VERSION = ENV.fetch("CAC_NFS_VERSION_3", true) ? 'vers=3': 'vers=4'

if CAC_SHARED_FOLDER_TYPE == "nfs"
if Vagrant::Util::Platform.linux? then
CAC_MOUNT_OPTIONS = ['rw', CAC_NFS_VERSION, 'tcp', 'nolock', 'actimeo=1']
else
CAC_MOUNT_OPTIONS = [CAC_NFS_VERSION, 'udp', 'actimeo=1']
end
else
if ENV.has_key?("CAC_MOUNT_OPTIONS")
CAC_MOUNT_OPTIONS = ENV.fetch("CAC_MOUNT_OPTIONS").split
else
CAC_MOUNT_OPTIONS = ["rw"]
end
end

if ENV['CAC_TRIPPLANNER_MEMORY'].nil?
# OpenTripPlanner needs > 1GB to build and run
CAC_MEMORY_MB = "8192"
Expand Down Expand Up @@ -88,7 +71,7 @@ VAGRANT_PROXYCONF_ENDPOINT = ENV["VAGRANT_PROXYCONF_ENDPOINT"]
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box = "bento/ubuntu-16.04"

# Wire up the proxy if:
#
Expand Down Expand Up @@ -132,12 +115,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "app" do |app|
app.vm.hostname = "app"
app.vm.network "private_network", ip: "192.168.8.24"

if testing?
app.vm.synced_folder ".", "/opt/app"
else
app.vm.synced_folder ".", "/opt/app", type: CAC_SHARED_FOLDER_TYPE, mount_options: CAC_MOUNT_OPTIONS
end
app.vm.synced_folder ".", "/opt/app"

# Web
app.vm.network "forwarded_port", guest: 443, host: 8024
Expand Down
2 changes: 2 additions & 0 deletions deployment/ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ postgres_host: "192.168.8.25"

packer_version: "1.0.2"

python_version: "2.7.*"

nodejs_version: 10.16.0
nodejs_npm_version: 6.9.0

Expand Down
5 changes: 3 additions & 2 deletions deployment/ansible/group_vars/development_template
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ default_admin_username: 'admin'
default_admin_password: 'admin'
default_admin_email: 'systems+cac@azavea.com'

postgresql_version: "9.4"
postgresql_package_version: "9.4.*.pgdg14.04+1"
postgresql_version: "9.5"
postgresql_package_version: "9.5.*"
postgresql_support_libpq_version: "*"

postgresql_listen_addresses: "*"
postgresql_hba_mapping:
Expand Down
5 changes: 3 additions & 2 deletions deployment/ansible/group_vars/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ production: false

postgis_version: [2, 1, 8]

postgresql_version: "9.4"
postgresql_package_version: "9.4.*.pgdg14.04+1"
postgresql_version: "9.5"
postgresql_package_version: "9.5.*"
postgresql_support_libpq_version: "*"

postgresql_listen_addresses: "*"
postgresql_hba_mapping:
Expand Down
2 changes: 1 addition & 1 deletion deployment/ansible/otp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
apt: update_cache=yes

roles:
- { role: "cac-tripplanner.otp-data"}
- {role: "cac-tripplanner.otp-data"}
6 changes: 3 additions & 3 deletions deployment/ansible/roles.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- src: azavea.opentripplanner
version: 1.2.0
version: 2.0.0

- src: azavea.nginx
version: 0.3.1
Expand All @@ -23,7 +23,7 @@
version: 0.1.0

- src: azavea.postgresql-support
version: 0.3.2
version: 0.4.0

- src: azavea.postgresql
version: 0.5.0
version: 1.0.0
19 changes: 1 addition & 18 deletions deployment/ansible/roles/cac-tripplanner.app/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,9 @@ app_sass_version: "3.4.22"

app_log: "/var/log/cac-tripplanner-app.log"

gunicorn_app_name: "cac-tripplanner-app"
root_app_dir: "/opt/app/python/cac_tripplanner"
root_conf_dir: "/etc/cac_tripplanner.d"
root_src_dir: "/opt/app/src"
root_static_dir: "/srv/cac"
root_media_dir: "/media/cac"

cac_python_dependencies:
- { name: 'base58', version: '1.0.3' }
- { name: 'boto', version: '2.49.0' }
- { name: 'django', version: '1.11.21' }
- { name: 'django-ckeditor', version: '5.7.1' }
- { name: 'django-image-cropping', version: '1.2.0' }
- { name: 'django-extensions', version: '1.9.9' }
- { name: 'django-storages', version: '1.7.1' }
- { name: 'easy-thumbnails', version: '2.6.0' }
- { name: 'gunicorn', version: '19.9.0' }
- { name: 'Pillow', version: '6.1.0' }
- { name: 'psycopg2-binary', version: '2.8.3' }
- { name: 'pytz', version: '2019.1' }
- { name: 'troposphere', version: '1.8.1' }
- { name: 'majorkirby', version: '0.2.1' }
# Note: django-wpadmin is installed manually to work around the fact that ansible-pip
# ignores editable=False
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Restart cac-tripplanner-app
service: name=cac-tripplanner-app state=restarted
service: name=cac-tripplanner-app use=sysv state=restarted

- name: Restart nginx
service: name=nginx state=restarted
service: name=nginx use=sysv state=restarted
48 changes: 30 additions & 18 deletions deployment/ansible/roles/cac-tripplanner.app/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# # Note bzip2 only installed here as workaround for unresolved but closed phantomjs
# install issue: https://github.com/Medium/phantomjs/issues/659
- name: Install packages
apt: name={{ item }} state=present
with_items:
- binutils
- bzip2
- gdal-bin
- libpq-dev
- libproj-dev
- python-dev
- libjpeg-dev
apt:
state: present
pkg:
- binutils
- bzip2
- gdal-bin
- libpq-dev
- libproj-dev
- python-dev
- libjpeg-dev

- name: Install pip packages
pip: name={{ item.name }} version={{ item.version }}
with_items: "{{ cac_python_dependencies }}"
pip: requirements={{ root_app_dir }}/requirements.txt

# Putting 'editable: false' in the entry in cac_python_dependencies should make it install
# non-editable, but it's getting ignored
Expand All @@ -41,15 +41,27 @@
- name: Write secrets file
template: src=cac_secrets.j2 dest=/etc/cac_secrets
when: develop or production
notify: Restart cac-tripplanner-app
notify: Restart {{ gunicorn_app_name }}

- name: Configure Gunicorn settings
template: src=gunicorn-cac-tripplanner.py.j2 dest={{ root_conf_dir }}/gunicorn.py
notify: Restart cac-tripplanner-app
notify: Restart {{ gunicorn_app_name }}

- name: Configure service definition
template: src=upstart-cac-tripplanner-app.conf.j2 dest=/etc/init/cac-tripplanner-app.conf
notify: Restart cac-tripplanner-app
template: src=systemd-{{ gunicorn_app_name }}.conf.j2
dest=/etc/systemd/system/{{ gunicorn_app_name }}.service
notify: Restart {{ gunicorn_app_name }}

- name: Enable gunicorn service
systemd:
name: "{{ gunicorn_app_name }}.service"
enabled: yes
daemon_reload: yes

- name: Enable nginx service
systemd:
name: "nginx.service"
enabled: yes

- name: Copy media assets
copy: src=../../python/cac_tripplanner/default_media
Expand All @@ -60,13 +72,13 @@

- name: Run migrations
django_manage: command=migrate
app_path=/opt/app/python/cac_tripplanner
notify: Restart cac-tripplanner-app
app_path="{{ root_app_dir }}"
notify: Restart {{ gunicorn_app_name }}
when: develop or test

- name: Run collectstatic
django_manage: command=collectstatic
app_path=/opt/app/python/cac_tripplanner
app_path="{{ root_app_dir }}"

- name: Copy nginx config
template: src=nginx-default.j2 dest=/etc/nginx/sites-available/default
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Unit]
Description = {{ gunicorn_app_name }}
After = network-online.target

[Service]
PermissionsStartOnly = true
User = {{ app_username }}
Group = {{ app_username }}
WorkingDirectory = {{ root_app_dir }}
ExecStart = /usr/bin/env gunicorn --config {{ root_conf_dir }}/gunicorn.py --timeout {{ otp_session_timeout_s }} cac_tripplanner.wsgi
ExecReload = /bin/kill -s HUP $MAINPID
ExecStop = /bin/kill -s TERM $MAINPID
PrivateTmp = true
StandardOutput = syslog
StandardError = syslog
SyslogIdentifier = {{ gunicorn_app_name }}

[Install]
{% if develop or test -%}
WantedBy = opt-app.mount
{% else %}
WantedBy = network-online.target
{% endif %}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
---
- name: Install PostGIS build dependencies
apt: pkg="{{ item }}" state=present
with_items:
- build-essential
- libgeos-dev
- libgdal-dev
- libproj-dev
- libjson0-dev
- libxml2-dev
- libxml2-utils
- xsltproc
- docbook-xsl
- docbook-mathml
apt:
state: present
pkg:
- build-essential
- libgeos-dev
- libgdal-dev
- libproj-dev
- libjson0-dev
- libxml2-dev
- libxml2-utils
- xsltproc
- docbook-xsl
- docbook-mathml

- name: Download PostGIS source tarball
unarchive: |
Expand Down
13 changes: 10 additions & 3 deletions deployment/ansible/roles/cac-tripplanner.otp-data/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
- name: Change owner and mode of byport file
file: path=/etc/authbind/byport/80 owner={{ otp_user }} mode=0755

- name: Overwrite upstart service
template: src=otp.conf.j2 dest=/etc/init/otp.conf
- name: Overwrite systemd service
template: src=otp.service.j2 dest=/etc/systemd/system/otp.service
register: otpconf

- name: Reload systemd
shell: systemctl daemon-reload
when: otpconf.changed
notify:
- Restart OpenTripPlanner

- name: Create data directory (test)
file: path=./otp_data/ owner={{ansible_user_id}} group={{ansible_user_id}} mode=0664 state=directory
Expand Down Expand Up @@ -43,7 +50,7 @@
when: test or (develop and not graph.stat.exists)

- name: Copy Built OTP Graph to Host (develop)
when: develop and graph_build|changed
when: develop and graph_build is changed
synchronize:
mode: pull
src: "{{ otp_data_dir }}/Graph.obj"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## NOTICE: This file is written by ansible, and any changes made here will be overwritten on
# next provision.
# Modify azavea.opentripplanner/templates/otp.service.j2 to make changes stick.

[Unit]
Description=Start OpenTripPlanner process
After={{ otp_service_after }}

[Service]
Type=simple
User={{ otp_user }}
WorkingDirectory={{ otp_bin_dir }}
Restart=on-failure
ExecStart=/usr/bin/authbind /usr/bin/java -Xmx{{otp_process_mem}} -jar {{ otp_bin_dir }}/{{ otp_jar_name }} --server --analyst --port 80 --basePath {{ otp_data_dir}} --graphs {{ otp_data_dir }} --router default

[Install]
WantedBy={{ otp_service_wantedby }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
dependencies:
- { role: "azavea.python", python_development: True }
- { role: "azavea.pip" }
- { role: "azavea.git" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
- name: Install pytz
pip: name=pytz
pip:
name: pytz
executable: pip2

- name: Install transitfeed
pip: name='git+https://github.com/google/transitfeed@1.2.15#egg=transitfeed'
pip:
name: 'git+https://github.com/google/transitfeed@1.2.15#egg=transitfeed'
executable: pip2
Loading