bundlewrap/bundles/homeassistant/items.py

79 lines
2.2 KiB
Python
Raw Normal View History

2024-03-07 07:23:04 +00:00
if node.has_bundle('pyenv'):
python_version = sorted(node.metadata.get('pyenv/python_versions'))[-1]
python_path = f'/opt/pyenv/versions/{python_version}/bin/python'
else:
python_path = '/usr/bin/python3'
2022-12-22 16:36:26 +00:00
users = {
'homeassistant': {
'home': '/var/opt/homeassistant',
},
}
directories = {
2022-12-22 17:59:27 +00:00
'/opt/homeassistant': {
'owner': 'homeassistant',
},
2022-12-22 16:36:26 +00:00
'/var/opt/homeassistant': {
'owner': 'homeassistant',
},
}
files = {
'/etc/systemd/system/homeassistant.service': {
'triggers': {
'action:systemd-reload',
'svc_systemd:homeassistant:restart',
},
},
2022-12-24 16:51:42 +00:00
'/usr/local/share/icinga/plugins/check_homeassistant_update': {
'content_type': 'mako',
'context': {
'bearer': repo.vault.decrypt(node.metadata.get('homeassistant/api_secret')),
'domain': node.metadata.get('homeassistant/domain'),
},
'mode': '0755',
},
2022-12-22 16:36:26 +00:00
}
actions = {
'homeassistant_create_virtualenv': {
2024-03-07 07:23:04 +00:00
'command': f'sudo -u homeassistant virtualenv -p {python_path} /opt/homeassistant/venv/',
2022-12-22 16:36:26 +00:00
'unless': 'test -d /opt/homeassistant/venv/',
'needs': {
2022-12-22 17:59:27 +00:00
'directory:/opt/homeassistant',
'user:homeassistant',
},
},
'homeassistant_install': {
'command': 'sudo -u homeassistant /opt/homeassistant/venv/bin/pip install homeassistant',
'unless': 'test -f /opt/homeassistant/venv/bin/hass',
'needs': {
'action:homeassistant_create_virtualenv',
2022-12-22 16:36:26 +00:00
'pkg_apt:bluez',
'pkg_apt:libffi-dev',
'pkg_apt:libssl-dev',
'pkg_apt:libjpeg-dev',
'pkg_apt:zlib1g-dev',
'pkg_apt:autoconf',
'pkg_apt:build-essential',
'pkg_apt:libopenjp2-7',
'pkg_apt:libtiff6',
2022-12-22 16:36:26 +00:00
'pkg_apt:libturbojpeg0-dev',
'pkg_apt:tzdata',
},
'triggers': {
'svc_systemd:homeassistant:restart',
},
},
}
svc_systemd = {
'homeassistant': {
'needs': {
'action:homeassistant_install',
'file:/etc/systemd/system/homeassistant.service',
},
},
}