From a286cc93d0d0cc44be89532b93f22894f55a6a44 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 24 Sep 2023 18:57:53 +0100 Subject: [PATCH] Copy tile logs to S3 --- cookbooks/tilelog/metadata.rb | 1 + cookbooks/tilelog/recipes/default.rb | 3 +++ cookbooks/tilelog/templates/default/tilelog.erb | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/cookbooks/tilelog/metadata.rb b/cookbooks/tilelog/metadata.rb index 0dba182a6..d3f5a753c 100644 --- a/cookbooks/tilelog/metadata.rb +++ b/cookbooks/tilelog/metadata.rb @@ -7,5 +7,6 @@ version "1.0.0" supports "ubuntu" depends "accounts" +depends "planet" depends "python" depends "systemd" diff --git a/cookbooks/tilelog/recipes/default.rb b/cookbooks/tilelog/recipes/default.rb index 2722c4f32..937022515 100644 --- a/cookbooks/tilelog/recipes/default.rb +++ b/cookbooks/tilelog/recipes/default.rb @@ -18,6 +18,7 @@ # include_recipe "accounts" +include_recipe "planet::aws" include_recipe "python" passwords = data_bag_item("tilelog", "passwords") @@ -57,6 +58,8 @@ exec_start "/usr/local/bin/tilelog" nice 10 sandbox :enable_network => true + protect_home "tmpfs" + bind_paths "/home/planet" read_write_paths tilelog_output_directory end diff --git a/cookbooks/tilelog/templates/default/tilelog.erb b/cookbooks/tilelog/templates/default/tilelog.erb index 0cb24ce4d..f00f2cb5d 100644 --- a/cookbooks/tilelog/templates/default/tilelog.erb +++ b/cookbooks/tilelog/templates/default/tilelog.erb @@ -4,6 +4,7 @@ set -e if [ -z "$DATE" ] then DATE=$(date -u -d "1 day ago" "+%Y-%m-%d") + YEAR=$(date -u -d "1 day ago" "+%Y") fi OUTDIR="<%= @output_dir %>" @@ -26,4 +27,9 @@ nice -n 19 /opt/tilelog/bin/tilelog --date "${DATE}" \ mv "${TILEFILE}" "${HOSTFILE}" "${APPFILE}" "${COUNTRYFILE}" "${OUTDIR}" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "${OUTDIR}/${TILEFILE}" "s3://osm-planet-eu-central-1/tile_logs/standard_layer/tiles/${YEAR}/${TILEFILE}" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "${OUTDIR}/${HOSTFILE}" "s3://osm-planet-eu-central-1/tile_logs/standard_layer/hosts/${YEAR}/${HOSTFILE}" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "${OUTDIR}/${APPFILE}" "s3://osm-planet-eu-central-1/tile_logs/standard_layer/apps/${YEAR}/${APPFILE}" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "${OUTDIR}/${COUNTRYFILE}" "s3://osm-planet-eu-central-1/tile_logs/standard_layer/countries/${YEAR}/${COUNTRYFILE}" + rm -rf "$TMPDIR"