Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Configure collections_publisher_db_admin machine class
Browse files Browse the repository at this point in the history
This creates a dedicated database admin machine for Collections
Publisher, following the Account API convention devised in #11342.
This is in order to facilitate the implementation of [RFC-143][],
which concludes that every GOV.UK relational database should have
its own RDS instance.

Trello: https://trello.com/c/HjK4AbUS/49-configure-puppet-for-new-db-admin-mysql-instances

[RFC-143]: https://github.com/alphagov/govuk-rfcs/blob/main/rfc-143-split-database-instances.md
  • Loading branch information
ChrisBAshton committed Dec 14, 2021
1 parent 23a78db commit eb9542b
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
govuk_env_sync::tasks:
"pull_collections_publisher_production_daily":
ensure: "present"
hour: "0"
minute: "0"
action: "pull"
dbms: "mysql"
storagebackend: "s3"
database: "collections_publisher_production"
database_hostname: "collections-publisher-mysql"
temppath: "/tmp/collections_publisher_production"
url: "govuk-production-database-backups"
path: "collections-publisher-mysql"
# "push_collections_publisher_production_daily":
# ensure: "present"
# hour: "5"
# minute: "0"
# action: "push"
# dbms: "mysql"
# storagebackend: "s3"
# database: "collections_publisher_production"
# database_hostname: "collections-publisher-mysql"
# temppath: "/tmp/collections_publisher_production"
# url: "govuk-integration-database-backups"
# path: "collections-publisher-mysql"
13 changes: 13 additions & 0 deletions hieradata_aws/class/production/collections_publisher_db_admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# govuk_env_sync::tasks:
# "push_collections_publisher_production_daily":
# ensure: "present"
# hour: "23"
# minute: "0"
# action: "push"
# dbms: "mysql"
# storagebackend: "s3"
# database: "collections_publisher_production"
# database_hostname: "collections-publisher-mysql"
# temppath: "/tmp/collections_publisher_production"
# url: "govuk-production-database-backups"
# path: "collections-publisher-mysql"
25 changes: 25 additions & 0 deletions hieradata_aws/class/staging/collections_publisher_db_admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
govuk_env_sync::tasks:
"pull_collections_publisher_production_daily":
ensure: "present"
hour: "0"
minute: "0"
action: "pull"
dbms: "mysql"
storagebackend: "s3"
database: "collections_publisher_production"
database_hostname: "collections-publisher-mysql"
temppath: "/tmp/collections_publisher_production"
url: "govuk-production-database-backups"
path: "collections-publisher-mysql"
# "push_collections_publisher_production_daily":
# ensure: "present"
# hour: "5"
# minute: "0"
# action: "push"
# dbms: "mysql"
# storagebackend: "s3"
# database: "collections_publisher_production"
# database_hostname: "collections-publisher-mysql"
# temppath: "/tmp/collections_publisher_production"
# url: "govuk-staging-database-backups"
# path: "collections-publisher-mysql"
3 changes: 3 additions & 0 deletions hieradata_aws/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ govuk::apps::ckan::s3_aws_secret_access_key: "%{hiera('s3_aws_secret_access_key'

govuk::apps::collections::unicorn_worker_processes: 8

# TODO: switch to "collections-publisher-mysql" and uncomment the 'push'
# `govuk_env_sync::tasks` tasks when we're ready to switch to the dedicated RDS instance
govuk::apps::collections_publisher::db_hostname: "mysql-primary"
govuk::apps::collections_publisher::jwt_auth_secret: "%{hiera('jwt_auth_secret')}"
govuk::apps::collections_publisher::redis_host: "%{hiera('sidekiq_host')}"
Expand Down Expand Up @@ -860,6 +862,7 @@ govuk::node::s_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_db_admin::apt_mirror_gpg_key_fingerprint: "%{hiera('apt_mirror_fingerprint')}"

govuk::node::s_account_api_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_collections_publisher_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_content_data_api_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"

govuk::node::s_gatling::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
Expand Down
45 changes: 45 additions & 0 deletions modules/govuk/manifests/node/s_collections_publisher_db_admin.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# == Class: govuk_node::s_collections_db_admin
#
# This machine class is used to administer the Collections Publisher
# MySQL RDS instances.
#
# === Parameters
#
# [*mysql_db_host*]
# The database hostname
#
# [*mysql_db_password*]
# The database password
#
# [*mysql_db_user*]
# The database user to connect to the remote database as
#
# [*apt_mirror_hostname*]
# The hostname for the apt mirror to add to enable fetching specific
# packages
#
# [*apt_mirror_gpg_key_fingerprint*]
# The fingerprint of the local aptly mirror.
#
class govuk::node::s_collections_publisher_db_admin(
$mysql_db_host = undef,
$mysql_db_password = undef,
$mysql_db_user = undef,
$mysql_backup_hour = 9,
$mysql_backup_min = 10,
$apt_mirror_hostname,
$apt_mirror_gpg_key_fingerprint,
) {
include ::govuk::node::s_base
include govuk_env_sync

file { '/root/.my.cnf':
ensure => 'present',
owner => 'root',
group => 'root',
content => template('govuk/node/s_db_admin/.my.cnf.erb'),
}

# include all MySQL classes that create databases and users
-> class { '::govuk::apps::collections_publisher::db': }
}
1 change: 1 addition & 0 deletions spec/fixtures/hieradata/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ govuk::deploy::sync::auth_token: "example-auth-token"
govuk::node::s_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_db_admin::apt_mirror_gpg_key_fingerprint: "%{hiera('apt_mirror_fingerprint')}"
govuk::node::s_account_api_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_collections_publisher_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_content_data_api_db_admin::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_graphite::apt_mirror_hostname: "%{hiera('apt_mirror_hostname')}"
govuk::node::s_graphite::apt_mirror_gpg_key_fingerprint: "%{hiera('apt_mirror_fingerprint')}"
Expand Down

0 comments on commit eb9542b

Please sign in to comment.