Skip to content

Commit

Permalink
Merge pull request #1378 from azavea/rm/upgrade-python-app-vm
Browse files Browse the repository at this point in the history
Upgrade Python to 3.10 in app VM and psycopg2 to 2.9
  • Loading branch information
rachelekm authored Mar 4, 2024
2 parents 84e9dcc + 778fe61 commit d1c3c70
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ CAC_APP_SHARED_FOLDER_TYPE=virtualbox vagrant up

Note that if there is an existing build Graph.obj in `otp_data`, vagrant provisioning in development mode will not attempt to rebuild the graph, but will use the one already present.

Django migrations are run as part of app provisioning, [here](https://github.com/azavea/cac-tripplanner/blob/develop/deployment/ansible/roles/cac-tripplanner.app/tasks/main.yml#L67-L72), but there may be instances where you need to manually run migrations outside of provisioning, in which case use the command:
```
vagrant ssh app -c 'cd /opt/app/python/cac_tripplanner && python3 manage.py migrate'
```


Building AMIs
------------------------
Expand Down
5 changes: 4 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ VAGRANT_PROXYCONF_ENDPOINT = ENV["VAGRANT_PROXYCONF_ENDPOINT"]
VAGRANTFILE_API_VERSION = "2"

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

# Wire up the proxy if:
#
Expand All @@ -86,6 +86,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end

config.vm.define "database" do |database|
# SSH issues bringing up DB VM with base box 22.04
# Explicitly define downgraded version for use by database until fix
database.vm.box = "bento/ubuntu-20.04"
database.vm.hostname = "database"
database.vm.network "private_network", ip: "192.168.56.25"

Expand Down
2 changes: 1 addition & 1 deletion deployment/ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ postgres_user: "cac_tripplanner"
postgres_password: "cac_tripplanner"
postgres_host: "192.168.56.25"

postgresql_support_psycopg2_version: "2.8.*"
postgresql_support_psycopg2_version: "2.9.*"
'postgis_version': [3, 0, 1]

packer_version: "1.5.4"
Expand Down
5 changes: 0 additions & 5 deletions deployment/ansible/roles.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
- src: azavea.opentripplanner
version: 2.0.1

- src: azavea.nginx
version: 1.0.0

- src: azavea.nodejs
version: 0.4.0

Expand All @@ -12,5 +9,3 @@

- src: azavea.papertrail
version: 2.0.0


2 changes: 1 addition & 1 deletion deployment/ansible/roles/cac-tripplanner.app/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
dependencies:
- { role: "azavea.git" }
- { role: "azavea.nginx" }
- { role: "azavea.nodejs" }
- { role: "azavea.packer" }
- { role: "cac-tripplanner.nginx" }
- { role: "cac-tripplanner.papertrail", when: production }
- { role: "cac-tripplanner.python3" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
nginx_delete_default_site: False
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Restart Nginx
service: name=nginx state=restarted
32 changes: 32 additions & 0 deletions deployment/ansible/roles/cac-tripplanner.nginx/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# Tasks and related artifacts copied from azavea.nginx role
# Customized to use Nginx Stable PPA that works with Ubuntu 22.04
- name: Configure the Nginx PPA
apt_repository: repo=ppa:ondrej/nginx state=present

- name: Install Nginx
apt: pkg=nginx-full state=present

- name: Delete default site
file: path=/etc/nginx/sites-enabled/default state=absent
register: delete_default_site
when: nginx_delete_default_site | bool
notify:
- Restart Nginx

- name: Delete default web root
file: path=/var/www/html state=absent
when: nginx_delete_default_site | bool and delete_default_site is changed

- name: Check Nginx Upstart service definition exists
stat: path=/etc/init/nginx.conf
register: nginx_upstart

- name: Configure Nginx log rotation
template: src=logrotate_nginx.j2 dest=/etc/logrotate.d/nginx
when: nginx_upstart.stat.exists

- name: Configure Nginx
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
notify:
- Restart Nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/var/log/nginx/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
service nginx rotate >/dev/null 2>&1
endscript
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
user www-data;
worker_processes {{ ansible_processor_count }};
pid /run/nginx.pid;

events {
worker_connections 768;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

server_tokens off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
2 changes: 1 addition & 1 deletion python/cac_tripplanner/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ easy-thumbnails==2.8.1
gunicorn==20.0.4
lxml==4.9.2
Pillow==7.2.0
psycopg2-binary==2.8.6
psycopg2-binary==2.9.0
pytz==2020.1
PyYAML==5.3.1
requests==2.24.0
Expand Down

0 comments on commit d1c3c70

Please sign in to comment.