2022-03-20 11:35:00 +00:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
2021-12-23 12:48:44 +00:00
|
|
|
defaults = {
|
|
|
|
'infobeamer-cms': {
|
|
|
|
'config': {
|
|
|
|
'MAX_UPLOADS': 5,
|
2022-03-20 11:35:00 +00:00
|
|
|
'PREFERRED_URL_SCHEME': 'https',
|
|
|
|
'SESSION_COOKIE_NAME': '__Host-sess',
|
2021-12-23 18:36:50 +00:00
|
|
|
'URL_KEY': repo.vault.password_for(f'{node.name} infobeamer-cms url key'),
|
2021-12-23 12:48:44 +00:00
|
|
|
'VERSION': 1,
|
|
|
|
},
|
2021-12-24 14:28:36 +00:00
|
|
|
'workers': 4,
|
2021-12-23 12:48:44 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
|
|
|
'nginx/vhosts',
|
|
|
|
)
|
|
|
|
def nginx(metadata):
|
|
|
|
if not node.has_bundle('nginx'):
|
|
|
|
raise DoNotRunAgain
|
|
|
|
|
|
|
|
return {
|
|
|
|
'nginx': {
|
2021-12-24 14:28:36 +00:00
|
|
|
'vhosts': {
|
|
|
|
'infobeamer-cms': {
|
|
|
|
'domain': node.metadata.get('infobeamer-cms/domain'),
|
|
|
|
'locations': {
|
|
|
|
'/': {
|
|
|
|
'target': 'http://127.0.0.1:8000',
|
|
|
|
},
|
|
|
|
'/static': {
|
|
|
|
'alias': '/opt/infobeamer-cms/src/static',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'website_check_path': '/',
|
|
|
|
'website_check_string': 'Share your projects',
|
|
|
|
},
|
|
|
|
},
|
2021-12-23 12:48:44 +00:00
|
|
|
},
|
|
|
|
}
|
2022-03-20 11:35:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
2023-12-26 13:49:04 +00:00
|
|
|
'infobeamer-cms/config/DOMAIN',
|
2022-03-20 11:35:00 +00:00
|
|
|
'infobeamer-cms/config/TIME_MAX',
|
|
|
|
'infobeamer-cms/config/TIME_MIN',
|
|
|
|
)
|
|
|
|
def event_times(metadata):
|
|
|
|
event_start = datetime.strptime(metadata.get('infobeamer-cms/event_start_date'), '%Y-%m-%d')
|
|
|
|
event_duration = metadata.get('infobeamer-cms/event_duration_days', 4)
|
|
|
|
|
|
|
|
event_end = event_start + timedelta(days=event_duration)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'infobeamer-cms': {
|
|
|
|
'config': {
|
2023-12-26 13:49:04 +00:00
|
|
|
'DOMAIN': metadata.get('infobeamer-cms/domain'),
|
2022-03-20 11:35:00 +00:00
|
|
|
'TIME_MAX': int(event_end.timestamp()),
|
|
|
|
'TIME_MIN': int(event_start.timestamp()),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|