Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
heffergm committed Sep 14, 2016
0 parents commit 272fbf9
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vagrant
.bundle
tmp/
Empty file added README.md
Empty file.
8 changes: 8 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default[:valhalla][:user] = 'valhalla'
default[:valhalla][:base_dir] = '/data'
default[:valhalla][:s3bucket] = 'mapzen.valhalla'
default[:valhalla][:s3bucket_dir] = 'prod'
default[:valhalla][:log_dir] = "#{node[:valhalla][:base_dir]}/logs"
default[:valhalla][:tile_dir] = "#{node[:valhalla][:base_dir]}/valhalla"
default[:valhalla][:transit_dir] = "#{node[:valhalla][:base_dir]}/valhalla/transit"
default[:valhalla][:elevation_dir] = "#{node[:valhalla][:base_dir]}/valhalla/elevation"
7 changes: 7 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name 'mapzen_valhalla-docker'
maintainer 'Mapzen'
maintainer_email '[email protected]'
license 'All rights reserved'
description 'Installs/Configures valhalla host systems'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.0.1'
31 changes: 31 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Cookbook Name:: mapzen_valhalla-docker
# Recipe:: default
#
# Copyright 2016, Mapzen
#
# All rights reserved - Do Not Redistribute
#

# make the valhalla user
user node[:valhalla][:user][:name] do
manage_home false
home node[:valhalla][:base_dir]
not_if { node[:valhalla][:user][:name] == 'root' }
end

# set up directory structure
dirs = [
node[:valhalla][:base_dir],
node[:valhalla][:log_dir],
node[:valhalla][:tile_dir],
node[:valhalla][:transit_dir],
node[:valhalla][:elevation_dir]
]

dirs.each do |d|
directory d do
owner node[:valhalla][:user]
recursive true
end
end
34 changes: 34 additions & 0 deletions recipes/get_routing_tiles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Cookbook Name:: mapzen_valhalla-docker
# Recipe:: default
#
# Copyright 2016, Mapzen
#
# All rights reserved - Do Not Redistribute
#

# go get the tiles
execute 'pull tiles' do
cwd node[:valhalla][:base_dir]
command <<-EOH
echo -n https://s3.amazonaws.com/#{node[:valhalla][:s3bucket]}/#{node[:valhalla][:s3bucket_dir]}/ > latest_tiles.txt &&
aws --region us-east-1 s3 ls s3://#{node[:valhalla][:s3bucket]}/#{node[:valhalla][:s3bucket_dir]}/ | grep -F tiles_ | awk '{print $4}' | sort | tail -n 1 >> latest_tiles.txt
EOH
end

# open them up
execute 'extract tiles' do
cwd node[:valhalla][:base_dir]
command <<-EOH
rm -rf tmp_tiles old_tiles &&
mkdir tmp_tiles &&
curl $(cat latest_tiles.txt) 2>#{node[:valhalla][:log_dir]}/curl_tiles.log | tar xzp -C tmp_tiles 2>#{node[:valhalla][:log_dir]}/untar_tiles.log
EOH
retries 3
end

# move them into place
execute 'move tiles' do
cwd node[:valhalla][:base_dir]
command "mv #{node[:valhalla][:tile_dir]} old_tiles; mv tmp_tiles #{node[:valhalla][:tile_dir]}"
end

0 comments on commit 272fbf9

Please sign in to comment.