From e6efb80e3363ef7ee084f6aee004a0b7dbb7a0e4 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Fri, 3 May 2024 03:11:05 +0100 Subject: [PATCH] Add birthday20 wordpress dev site --- cookbooks/blog/recipes/birthday.rb | 59 +++++++++++++++++++ .../default/backup-birthday20.cron.erb | 21 +++++++ roles/birthday20.rb | 19 ++++++ roles/fume.rb | 3 +- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 cookbooks/blog/recipes/birthday.rb create mode 100644 cookbooks/blog/templates/default/backup-birthday20.cron.erb create mode 100644 roles/birthday20.rb diff --git a/cookbooks/blog/recipes/birthday.rb b/cookbooks/blog/recipes/birthday.rb new file mode 100644 index 000000000..eac984ae0 --- /dev/null +++ b/cookbooks/blog/recipes/birthday.rb @@ -0,0 +1,59 @@ +# +# Cookbook:: blog +# Recipe:: birthday +# +# Copyright:: 2024, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "wordpress" + +passwords = data_bag_item("birthday20", "passwords") +wp2fa_encrypt_keys = data_bag_item("birthday20", "wp2fa_encrypt_keys") + +directory "/srv/birthday20.openstreetmap.org" do + owner "wordpress" + group "wordpress" + mode "755" +end + +wordpress_site "birthday20.openstreetmap.org" do + aliases ["birthday20.osm.org", "birthday20.openstreetmap.com", + "birthday20.openstreetmap.net", "birthday20.openstreetmaps.org"] + directory "/srv/birthday20.openstreetmap.org/wp" + database_name "osm-birthday20" + database_user "osm-birthday20-user" + database_password passwords["osm-birthday20-user"] + wp2fa_encrypt_key wp2fa_encrypt_keys["key"] + fpm_prometheus_port 11403 +end + +wordpress_plugin "birthday20.openstreetmap.org-shareadraft" do + action :delete + plugin "shareadraft" + site "birthday20.openstreetmap.org" +end + +wordpress_plugin "birthday20.openstreetmap.org-public-post-preview" do + plugin "public-post-preview" + site "birthday20.openstreetmap.org" +end + +template "/etc/cron.daily/birthday20-backup" do + source "backup-birthday20.cron.erb" + owner "root" + group "root" + mode "750" + variables :passwords => passwords +end diff --git a/cookbooks/blog/templates/default/backup-birthday20.cron.erb b/cookbooks/blog/templates/default/backup-birthday20.cron.erb new file mode 100644 index 000000000..cef3d14ee --- /dev/null +++ b/cookbooks/blog/templates/default/backup-birthday20.cron.erb @@ -0,0 +1,21 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +T=$(mktemp -d -t -p /var/tmp osm-birthday20.XXXXXXXXXX) +D=$(date +%Y-%m-%d) +B=osm-birthday20-$D.tar.gz + +mkdir $T/osm-birthday20-$D +echo '[mysqldump]' > $T/mysqldump.opts +echo 'user=osm-birthday20-user' >> $T/mysqldump.opts +echo 'password=<%= @passwords["osm-birthday20-user"] %>' >> $T/mysqldump.opts +mysqldump --defaults-file=$T/mysqldump.opts --opt --no-tablespaces osm-birthday20 > $T/osm-birthday20-$D/osm-birthday20.sql +ln -s /srv/birthday20.openstreetmap.org $T/osm-birthday20-$D/www + +export RSYNC_RSH="ssh -ax" + +nice tar --create --dereference --directory=$T --warning=no-file-changed osm-birthday20-$D | nice gzip --rsyncable -9 > $T/$B +nice rsync --preallocate --fuzzy $T/$B backup::backup + +rm -rf $T diff --git a/roles/birthday20.rb b/roles/birthday20.rb new file mode 100644 index 000000000..ea83dc13b --- /dev/null +++ b/roles/birthday20.rb @@ -0,0 +1,19 @@ +name "birthday20" +description "Role applied to birthday20 servers" + +default_attributes( + :accounts => { + :users => { + :mikel => { :status => :administrator }, + :wordpress => { + :status => :role, + :members => [:mikel] + } + }, + } +) + +# FIXME: Disable while site under development +run_list( + "recipe[blog::birthday20]" +) diff --git a/roles/fume.rb b/roles/fume.rb index 5b4c5a670..6af2333b4 100644 --- a/roles/fume.rb +++ b/roles/fume.rb @@ -33,5 +33,6 @@ default_attributes( run_list( "role[equinix-dub]", - "role[blog-staging]" + "role[blog-staging]", + "role[birthday20]" ) -- 2.39.5