home.hass: use pyenv for homeassistant

This commit is contained in:
Franzi 2024-03-07 08:23:04 +01:00
parent ac10630fb9
commit 4d92211862
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 13 additions and 2 deletions

View file

@ -1,3 +1,9 @@
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'
users = { users = {
'homeassistant': { 'homeassistant': {
'home': '/var/opt/homeassistant', 'home': '/var/opt/homeassistant',
@ -32,7 +38,7 @@ files = {
actions = { actions = {
'homeassistant_create_virtualenv': { 'homeassistant_create_virtualenv': {
'command': 'sudo -u homeassistant /usr/bin/python3 -m virtualenv -p python3 /opt/homeassistant/venv/', 'command': f'sudo -u homeassistant virtualenv -p {python_path} /opt/homeassistant/venv/',
'unless': 'test -d /opt/homeassistant/venv/', 'unless': 'test -d /opt/homeassistant/venv/',
'needs': { 'needs': {
'directory:/opt/homeassistant', 'directory:/opt/homeassistant',

View file

@ -1,7 +1,8 @@
hostname = "172.19.138.25" hostname = "172.19.138.25"
bundles = [ bundles = [
'homeassistant', 'homeassistant',
'nginx' 'nginx',
'pyenv',
] ]
groups = ["debian-bookworm"] groups = ["debian-bookworm"]
@ -26,5 +27,9 @@ restrict-to = [
'172.19.138.0/24', '172.19.138.0/24',
] ]
[metadata.pyenv]
version = 'v2.3.36'
python_versions = ["3.12.2"]
[metadata.nginx.vhosts.homeassistant] [metadata.nginx.vhosts.homeassistant]
ssl = '_.home.kunbox.net' ssl = '_.home.kunbox.net'