This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure account_api_db_admin machine class
This creates a dedicated database admin machine for the Account API, following the content_data_api_db_admin convention. 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. [RFC-143]: https://github.com/alphagov/govuk-rfcs/blob/main/rfc-143-split-database-instances.md
- Loading branch information
1 parent
9b78501
commit 4e0cb1d
Showing
7 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
govuk_env_sync::tasks: | ||
"pull_account_api_production_daily": | ||
ensure: "present" | ||
hour: "0" | ||
minute: "0" | ||
action: "pull" | ||
dbms: "postgresql" | ||
storagebackend: "s3" | ||
database: "account-api_production" | ||
temppath: "/tmp/account_api_production" | ||
url: "govuk-production-database-backups" | ||
path: "account-api-postgresql" | ||
"push_account_api_production_daily": | ||
ensure: "present" | ||
hour: "5" | ||
minute: "0" | ||
action: "push" | ||
dbms: "postgresql" | ||
storagebackend: "s3" | ||
database: "account-api_production" | ||
temppath: "/tmp/account_api_production" | ||
url: "govuk-integration-database-backups" | ||
path: "account-api-postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
govuk_env_sync::tasks: | ||
"push_account_api_production_daily": | ||
ensure: "present" | ||
hour: "23" | ||
minute: "0" | ||
action: "push" | ||
dbms: "postgresql" | ||
storagebackend: "s3" | ||
database: "account-api_production" | ||
temppath: "/tmp/account_api_production" | ||
url: "govuk-production-database-backups" | ||
path: "account-api-postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
govuk_env_sync::tasks: | ||
"pull_account_api_production_daily": | ||
ensure: "present" | ||
hour: "0" | ||
minute: "0" | ||
action: "pull" | ||
dbms: "postgresql" | ||
storagebackend: "s3" | ||
database: "account-api_production" | ||
temppath: "/tmp/account_api_production" | ||
url: "govuk-production-database-backups" | ||
path: "account-api-postgresql" | ||
"push_account_api_production_daily": | ||
ensure: "present" | ||
hour: "5" | ||
minute: "0" | ||
action: "push" | ||
dbms: "postgresql" | ||
storagebackend: "s3" | ||
database: "account-api_production" | ||
temppath: "/tmp/account_api_production" | ||
url: "govuk-staging-database-backups" | ||
path: "account-api-postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# == Class: govuk_node::s_account_api_db_admin | ||
# | ||
# This machine class is used to administer the Account API | ||
# PostgreSQL RDS instances. | ||
# | ||
# === Parameters | ||
# | ||
# [*postgres_host*] | ||
# Hostname of the RDS database to use. | ||
# Default: undef | ||
# | ||
# [*postgres_user*] | ||
# The PostgreSQL user to use for admisistering the database. | ||
# Default: undef | ||
# | ||
# [*postgres_password*] | ||
# The password corresponding to the above `postgres_user`. | ||
# Default: undef | ||
# | ||
# [*postgres_port*] | ||
# The port with which to connect to the `postgres_host`. | ||
# Default: '5432' | ||
# | ||
class govuk::node::s_account_api_db_admin( | ||
$postgres_host = undef, | ||
$postgres_user = undef, | ||
$postgres_password = undef, | ||
$postgres_port = '5432', | ||
$apt_mirror_hostname, | ||
) { | ||
include govuk_env_sync | ||
include ::govuk::node::s_base | ||
|
||
# This allows easy administration of the PostgreSQL backend: | ||
# https://www.postgresql.org/docs/9.3/static/libpq-pgpass.html | ||
file { '/root/.pgpass': | ||
ensure => present, | ||
mode => '0600', | ||
content => "${postgres_host}:5432:*:${postgres_user}:${postgres_password}", | ||
} | ||
|
||
# Unfortunately, the prior art for configuring db-admin style | ||
# machines seems to involve a redundant PostgreSQL service, just to | ||
# satisfy the Puppet module used to configure PostgreSQL running on | ||
# the RDS instance. Some of the below configuration relates to this. | ||
|
||
# Connect to the RDS instance when performing Puppet operations | ||
$default_connect_settings = { | ||
'PGUSER' => $postgres_user, | ||
'PGPASSWORD' => $postgres_password, | ||
'PGHOST' => $postgres_host, | ||
'PGPORT' => $postgres_port, | ||
} | ||
|
||
apt::source { 'postgresql': | ||
ensure => present, | ||
location => "http://${apt_mirror_hostname}/postgresql", | ||
release => "${::lsbdistcodename}-pgdg", | ||
architecture => $::architecture, | ||
key => 'B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8', | ||
} -> | ||
|
||
# We don't actually want to run a local PostgreSQL server, just | ||
# configure the RDS one | ||
class { '::postgresql::server': | ||
default_connect_settings => $default_connect_settings, | ||
service_manage => false, | ||
} -> | ||
|
||
service { 'postgresql': | ||
ensure => stopped, | ||
} | ||
|
||
include ::govuk_postgresql::server::not_slave | ||
|
||
# Ensure the client class is installed | ||
class { '::govuk_postgresql::client': } -> | ||
|
||
# include all PostgreSQL classes that create databases and users | ||
class { '::govuk::apps::account_api::db': } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters