Skip to content

Commit

Permalink
Merge branch 'release/3.1.44'
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelekm committed Mar 6, 2024
2 parents d58ad54 + d1c3c70 commit 8ea3986
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 28 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/*;
}
34 changes: 22 additions & 12 deletions deployment/cloudformation/privatehostedzone.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from boto import route53

from majorkirby import CustomActionNode

import json

import boto3
import uuid

class R53PrivateHostedZone(CustomActionNode):
"""Represents a Route53 private hosted zone"""
Expand All @@ -19,21 +18,32 @@ class R53PrivateHostedZone(CustomActionNode):

def action(self):
"""Creates the zone"""
conn = route53.connect_to_region(self.REGION)
client = boto3.client('route53', region_name=self.REGION)
comment = json.dumps(self.get_raw_tags())

hosted_zones = conn.get_all_hosted_zones()
hosted_zones = client.list_hosted_zones()

for hosted_zone in hosted_zones['ListHostedZonesResponse']['HostedZones']:
for hosted_zone in hosted_zones['HostedZones']:
if ('Comment' in hosted_zone['Config'] and
hosted_zone['Config']['Comment'] == comment):
self.stack_outputs = {'PrivateHostedZoneId': hosted_zone['Id'].split('/')[-1]}
return

hosted_zone = conn.create_hosted_zone(self.get_input('PrivateHostedZoneName'),
comment=comment,
private_zone=True,
vpc_id=self.get_input('VpcId'),
vpc_region=self.REGION)

vpc_config = {
'VPCRegion': self.REGION,
'VPCId': self.get_input("VpcId")
}
hosted_zone_config = {
'Comment': comment,
'PrivateZone': True
}

hosted_zone = client.create_hosted_zone(
Name=self.get_input("PrivateHostedZoneName"),
CallerReference=str(uuid.uuid4()),
HostedZoneConfig=hosted_zone_config,
VPC=vpc_config,
)
hosted_zone_id = hosted_zone['CreateHostedZoneResponse']['HostedZone']['Id']
self.stack_outputs = {'PrivateHostedZoneId': hosted_zone_id.split('/')[-1]}

11 changes: 5 additions & 6 deletions deployment/cloudformation/utils/cfn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Helper functions and classes for dealing with cloudformation"""
import boto
import boto3


class AvailabilityZone(object):
Expand All @@ -15,7 +15,6 @@ def __init__(self, availability_zone):
Args:
availability_zone (AvailabilityZone): boto object
"""

self.availability_zone = availability_zone

@property
Expand All @@ -24,12 +23,12 @@ def cfn_name(self):
Utility method to return a string appropriate for CloudFormation
name of a resource (e.g. UsEast1a)
"""
return self.availability_zone.name.title().replace('-', '')
return self.availability_zone['ZoneName'].title().replace('-', '')

@property
def name(self):
"""Utility function to return the name of an availability zone (e.g. us-east-1a)"""
return self.availability_zone.name
return self.availability_zone['ZoneName']


def get_availability_zones():
Expand All @@ -38,5 +37,5 @@ def get_availability_zones():
Returns:
(list of AvailabilityZone): List of availability zones for a given EC2 region
"""
conn = boto.connect_ec2()
return [AvailabilityZone(az) for az in conn.get_all_zones()]
client = boto3.client('ec2', region_name='us-east-1')
return [AvailabilityZone(az) for az in client.describe_availability_zones()['AvailabilityZones']]
3 changes: 2 additions & 1 deletion python/cac_tripplanner/deployment_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
boto==2.49.0
boto3==1.15.9
PyYAML==5.3.1
majorkirby==1.0.0
requests==2.24.0
troposphere==3.2.2
uuid==1.30.0
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 8ea3986

Please sign in to comment.