Skip to content

Commit

Permalink
Recipe needs the right variables and data bags
Browse files Browse the repository at this point in the history
  • Loading branch information
grischard authored Aug 5, 2024
1 parent bfd4efb commit d64c557
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cookbooks/web/recipes/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
include_recipe "web::cgimap"

web_passwords = data_bag_item("web", "passwords")
admins = data_bag_item("apache", "admins")

apache_module "alias"
apache_module "expires"
Expand Down Expand Up @@ -69,10 +70,29 @@

cloudflare_ipv6 = IO.read("#{Chef::Config[:file_cache_path]}/cloudflare-ipv6-list").lines.map(&:chomp)

remote_file "#{Chef::Config[:file_cache_path]}/fastly-ip-list.json" do
source "https://api.fastly.com/public-ip-list"
compile_time true
ignore_failure true
end

fastlyips = JSON.parse(IO.read("#{Chef::Config[:file_cache_path]}/fastly-ip-list.json"))

remote_file "#{Chef::Config[:file_cache_path]}/statuscake-locations.json" do
source "https://app.statuscake.com/Workfloor/Locations.php?format=json"
compile_time true
ignore_failure true
end

statuscakelocations = JSON.parse(IO.read("#{Chef::Config[:file_cache_path]}/statuscake-locations.json"))

apache_site "www.openstreetmap.org" do
template "apache.frontend.erb"
variables :cloudflare => cloudflare_ipv4 + cloudflare_ipv6,
:fastly => fastlyips["addresses"] + fastlyips["ipv6_addresses"],
:statuscake => statuscakelocations.flat_map { |_, v| [v["ip"], v["ipv6"]] },
:status => node[:web][:status],
:admins => admins["hosts"],
:secret_key_base => web_passwords["secret_key_base"]
end

Expand Down

0 comments on commit d64c557

Please sign in to comment.