2020-08-21 13:06:04 +00:00
|
|
|
from os.path import isfile, join
|
|
|
|
|
2020-08-19 16:43:32 +00:00
|
|
|
pkg_apt = {
|
|
|
|
'perl': {},
|
|
|
|
'cpanminus': {},
|
|
|
|
}
|
|
|
|
|
2020-11-10 12:23:22 +00:00
|
|
|
users = {
|
|
|
|
'travelynx': {
|
|
|
|
'home': '/opt/travelynx',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-08-19 16:43:32 +00:00
|
|
|
directories = {
|
2021-07-02 13:48:48 +00:00
|
|
|
'/opt/travelynx': {},
|
2020-08-19 16:43:32 +00:00
|
|
|
'/var/cache/travelynx': {
|
|
|
|
'owner': 'travelynx',
|
|
|
|
'mode': '0700',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
files = {
|
|
|
|
'/etc/systemd/system/travelynx.service': {
|
|
|
|
'triggers': {
|
|
|
|
'action:systemd-reload',
|
2020-10-16 11:03:52 +00:00
|
|
|
'svc_systemd:travelynx:restart',
|
|
|
|
'svc_systemd:travelynx-worker:restart',
|
2020-08-19 16:43:32 +00:00
|
|
|
},
|
|
|
|
},
|
2020-08-19 19:51:03 +00:00
|
|
|
'/etc/systemd/system/travelynx-worker.service': {
|
|
|
|
'triggers': {
|
|
|
|
'action:systemd-reload',
|
2020-10-16 11:03:52 +00:00
|
|
|
'svc_systemd:travelynx:restart',
|
|
|
|
'svc_systemd:travelynx-worker:restart',
|
2020-08-19 19:51:03 +00:00
|
|
|
},
|
|
|
|
},
|
2020-08-19 16:43:32 +00:00
|
|
|
'/opt/travelynx/travelynx.conf': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': node.metadata['travelynx'],
|
|
|
|
'needs': {
|
|
|
|
'git_deploy:/opt/travelynx',
|
|
|
|
},
|
2020-08-19 16:51:27 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:travelynx:restart',
|
2020-10-16 11:03:52 +00:00
|
|
|
'svc_systemd:travelynx-worker:restart',
|
2020-08-19 16:51:27 +00:00
|
|
|
},
|
2020-08-19 16:43:32 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-08-21 13:06:04 +00:00
|
|
|
if isfile(join(repo.path, 'data', 'travelynx', 'files', 'imprint', node.name)):
|
|
|
|
files['/opt/travelynx/templates/imprint.html.ep'] = {
|
|
|
|
'source': 'imprint/{}'.format(node.name),
|
|
|
|
'needs': {
|
|
|
|
'git_deploy:/opt/travelynx',
|
|
|
|
},
|
2020-09-12 15:08:18 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:travelynx:restart',
|
|
|
|
},
|
2020-08-21 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
2020-08-19 16:43:32 +00:00
|
|
|
git_deploy = {
|
|
|
|
'/opt/travelynx': {
|
2020-08-19 17:06:59 +00:00
|
|
|
'repo': 'https://github.com/derf/travelynx.git',
|
2020-08-20 07:44:01 +00:00
|
|
|
'rev': node.metadata['travelynx']['version'],
|
2021-07-02 13:48:48 +00:00
|
|
|
'needs': {
|
|
|
|
'directory:/opt/travelynx',
|
|
|
|
},
|
2020-08-19 16:43:32 +00:00
|
|
|
'triggers': {
|
|
|
|
'action:travelynx_install_deps',
|
|
|
|
'action:travelynx_database_migrate',
|
|
|
|
'svc_systemd:travelynx:restart',
|
2020-10-16 11:03:52 +00:00
|
|
|
'svc_systemd:travelynx-worker:restart',
|
2020-08-19 16:43:32 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
actions = {
|
|
|
|
'travelynx_install_deps': {
|
|
|
|
'command': 'cd /opt/travelynx && cpanm -in --no-man-pages --installdeps .',
|
|
|
|
'needs': {
|
|
|
|
'pkg_apt:perl',
|
|
|
|
'pkg_apt:cpanminus',
|
|
|
|
},
|
|
|
|
'triggered': True,
|
|
|
|
},
|
|
|
|
'travelynx_database_migrate': {
|
|
|
|
'command': 'cd /opt/travelynx && perl index.pl database migrate',
|
|
|
|
# Because git_deploy does not put .git onto the server, the script
|
|
|
|
# will complain on STDERR about not finding a git repository.
|
|
|
|
# That's why we need to redirect stderr to /dev/null.
|
|
|
|
'unless': 'cd /opt/travelynx && [ $(perl index.pl database has-current-schema 2>/dev/null) = "yes" ]',
|
|
|
|
'needs': {
|
|
|
|
'action:travelynx_install_deps',
|
|
|
|
'file:/opt/travelynx/travelynx.conf',
|
|
|
|
'postgres_db:travelynx',
|
|
|
|
'postgres_role:travelynx',
|
|
|
|
},
|
|
|
|
'triggered': True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
svc_systemd = {
|
|
|
|
'travelynx': {
|
|
|
|
'needs': {
|
|
|
|
'file:/etc/systemd/system/travelynx.service',
|
|
|
|
'action:travelynx_database_migrate',
|
|
|
|
'directory:/var/cache/travelynx',
|
|
|
|
},
|
|
|
|
},
|
2020-08-19 19:51:03 +00:00
|
|
|
'travelynx-worker': {
|
|
|
|
'needs': {
|
|
|
|
'file:/etc/systemd/system/travelynx-worker.service',
|
|
|
|
'svc_systemd:travelynx',
|
|
|
|
},
|
|
|
|
},
|
2020-08-19 16:43:32 +00:00
|
|
|
}
|