-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SSH & HTTP connections * Rename env template * Add Airflow logs bucket to startup * Add basic deployment DAG * Add CODEOWNERS * Add other services * Add IS_PROD variable setting
- Loading branch information
1 parent
2a33bc7
commit 8ee9dcc
Showing
6 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @OrcaCollective/team |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SSH_MASTODON_CONN_ID = "ssh_mastodon" | ||
SSH_MONOLITH_CONN_ID = "ssh_monolith" | ||
|
||
MATRIX_WEBHOOK_CONN_ID = "matrix_webhook" | ||
MATRIX_WEBHOOK_API_KEY = "matrix_webhook_api_key" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import json | ||
from datetime import datetime | ||
|
||
import constants | ||
from airflow.decorators import dag | ||
from airflow.providers.http.operators.http import SimpleHttpOperator | ||
from airflow.providers.ssh.operators.ssh import SSHOperator | ||
|
||
|
||
SERVICES = [ | ||
"1-312-hows-my-driving", | ||
"spd-data-watch", | ||
"OpenOversight", | ||
"spd-lookup", | ||
] | ||
|
||
|
||
for service in SERVICES: | ||
service_name = service.replace("-", "_") | ||
dag_id = f"deploy_{service_name}" | ||
|
||
@dag( | ||
dag_id=dag_id, | ||
start_date=datetime(2022, 11, 24), | ||
catchup=False, | ||
schedule=None, | ||
tags=["deployment"], | ||
) | ||
def deployment_dag(): | ||
|
||
ssh_deploy = SSHOperator( | ||
task_id=f"deploy_{service_name}", | ||
ssh_conn_id=constants.SSH_MONOLITH_CONN_ID, | ||
command="cd {{ params.service }} && just deploy", | ||
# Note that AcceptEnv has to be set for IS_PROD on the host | ||
# or this will fail silently!! | ||
# https://airflow.apache.org/docs/apache-airflow-providers-ssh/stable/_api/airflow/providers/ssh/operators/ssh/index.html#airflow.providers.ssh.operators.ssh.SSHOperator # noqa | ||
environment={"IS_PROD": "true"}, | ||
params={ | ||
"service": service, | ||
}, | ||
) | ||
|
||
matrix_alert = SimpleHttpOperator( | ||
task_id=f"notify_{service_name}_deploy", | ||
http_conn_id=constants.MATRIX_WEBHOOK_CONN_ID, | ||
data=json.dumps( | ||
{ | ||
"key": "{{ var.value.matrix_webhook_api_key }}", | ||
"body": f"Deployment complete for `{service}`", | ||
} | ||
), | ||
) | ||
|
||
ssh_deploy >> matrix_alert | ||
|
||
deployment_dag() |