Add configuration file
This commit is contained in:
parent
6119d17c70
commit
56f0d18b11
2 changed files with 64 additions and 5 deletions
|
@ -27,17 +27,48 @@
|
|||
# [*ruby_version*]
|
||||
# String with the ruby version to use. Default: 3.2.2
|
||||
#
|
||||
# [*mastodon_config*]
|
||||
# Hash with the configuration to store in .env.production
|
||||
#
|
||||
class mastodon (
|
||||
String $ensure = 'present',
|
||||
String $hostname = 'mastodon.example.org',
|
||||
String $smtp_server = 'mail.example.org',
|
||||
String $mastodon_home = '/opt/mastodon',
|
||||
String $db_host = '/var/run/postgresql',
|
||||
String $db_name = 'mastodon',
|
||||
String $db_user = 'mastodon',
|
||||
String $db_password = 'S3cr3TP4ssw0rd',
|
||||
Integer $db_port = 5432,
|
||||
String $mastodon_version = 'v4.2.1',
|
||||
String $ruby_version = '3.2.2',
|
||||
String $mastodon_user = 'mastodon',
|
||||
String $mastodon_group = 'mastodon',
|
||||
String $secret_key_base = 'S3cr3tK3i',
|
||||
String $otp_secret = '0tpS3cr3t',
|
||||
String $vapid_private_key = 'S3cr3tK3i',
|
||||
String $vapid_public_key = 'S3cr3tK3i',
|
||||
Hash $mastodon_config = {
|
||||
'LOCAL_DOMAIN' => 'example.com',
|
||||
'REDIS_HOST' => '127.0.0.1',
|
||||
'REDIS_PORT' => 6379,
|
||||
'ES_ENABLED' => 'false',
|
||||
'ES_HOST' => 'localhost',
|
||||
'ES_PORT' => 9200,
|
||||
'ES_USER' => 'elastic',
|
||||
'ES_PASS' => 'password',
|
||||
'SMTP_SERVER' => '',
|
||||
'SMTP_PORT' => 587,
|
||||
'SMTP_LOGIN' => '',
|
||||
'SMTP_PASSWORD' => '',
|
||||
'SMTP_FROM_ADDRESS' => 'notifications@example.com',
|
||||
'S3_ENABLED' => 'false',
|
||||
'S3_BUCKET' => 'files.example.com',
|
||||
'AWS_ACCESS_KEY_ID' => '',
|
||||
'AWS_SECRET_ACCESS_KEY' => '',
|
||||
'S3_ALIAS_HOST' => 'files.example.com',
|
||||
'IP_RETENTION_PERIOD' => 31556952,
|
||||
'SESSION_RETENTION_PERIOD' => 31556952,
|
||||
},
|
||||
) {
|
||||
case $ensure {
|
||||
default: {
|
||||
|
@ -169,9 +200,9 @@ class mastodon (
|
|||
group => $mastodon_group,
|
||||
require => Vcsrepo['rbenv'],
|
||||
}
|
||||
postgresql::server::db { 'mastodon':
|
||||
user => 'mastodon',
|
||||
password => postgresql::postgresql_password('mastodon', $db_password),
|
||||
postgresql::server::db { $db_name:
|
||||
user => $db_user,
|
||||
password => postgresql::postgresql_password($db_user, $db_password),
|
||||
}
|
||||
vcsrepo { 'mastodon_code':
|
||||
path => "${mastodon_home}/live",
|
||||
|
@ -190,7 +221,7 @@ class mastodon (
|
|||
group => 'root',
|
||||
require => [
|
||||
Vcsrepo['mastodon_code'],
|
||||
Postgresql::Server::Db['mastodon'],
|
||||
Postgresql::Server::Db[$db_name],
|
||||
Vcsrepo['ruby_build'],
|
||||
],
|
||||
}
|
||||
|
@ -208,4 +239,27 @@ class mastodon (
|
|||
timeout => 0,
|
||||
require => File['/usr/local/bin/install_mastodon.sh'],
|
||||
}
|
||||
$real_config = $mastodon_config + {
|
||||
LOCAL_DOMAIN => $hostname,
|
||||
DB_PASS => $db_password,
|
||||
DB_USER => $db_user,
|
||||
DB_NAME => $db_name,
|
||||
DB_PORT => $db_port,
|
||||
DB_HOST => $db_host,
|
||||
SECRET_KEY_BASE => $secret_key_base,
|
||||
OTP_SECRET => $otp_secret,
|
||||
}
|
||||
file { "${mastodon_home}/live/.env.production":
|
||||
ensure => $ensure,
|
||||
content => template('mastodon/env.production.erb'),
|
||||
mode => '0640',
|
||||
owner => $mastodon_user,
|
||||
group => $mastodon_group,
|
||||
require => [
|
||||
Vcsrepo['mastodon_code'],
|
||||
],
|
||||
}
|
||||
# RAILS_ENV=production rails db:setup
|
||||
# db:create
|
||||
# RAILS_ENV=production rails assets:precompile
|
||||
}
|
||||
|
|
5
templates/env.production.erb
Normal file
5
templates/env.production.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# This file was generated by Puppet
|
||||
|
||||
<% @real_config.each_pair do |field, value| -%>
|
||||
<%= field %>=<%= value %>
|
||||
<% end -%>
|
Loading…
Reference in a new issue