Kaynağa Gözat

Use the home_assistant user for most tasks

This updates the formula to use the home_assistant user for tasks like
cloning the git repo and making the virtual environment. This allows
home assistant to perform some tasks it otherwise can't do due to
permission issues, like installing needed python libraries at runtime.

This also allows the ssh identity used for cloning the git repo to be
specified.

Signed-off-by: M. David Bennett <mdavidbennett@syntheticworks.com>
pull/4/head
M. David Bennett 5 yıl önce
ebeveyn
işleme
dda3625ae7
2 değiştirilmiş dosya ile 15 ekleme ve 18 silme
  1. +1
    -0
      README.rst
  2. +14
    -18
      home_assistant/server.sls

+ 1
- 0
README.rst Dosyayı Görüntüle

@@ -35,6 +35,7 @@ home-assistant service wit git based configuration
engine: git
address: '${_param:home_assistant_config_repository}'
branch: ${_param:home_assistant_config_revision}
identity: /path/to/optional/ssh/identity/file


References

+ 14
- 18
home_assistant/server.sls Dosyayı Görüntüle

@@ -5,13 +5,21 @@ home_assistant_packages:
pkg.installed:
- names: {{ server.pkgs }}

home_assistant_user:
user.present:
- name: home_assistant
- system: true
- home: {{ server.dir.base }}

{{ server.dir.base }}:
virtualenv.manage:
- user: home_assistant
- system_site_packages: True
- requirements: salt://home_assistant/files/requirements.txt
- python: /usr/bin/python3
- require:
- pkg: home_assistant_packages
- user: home_assistant_user

home_assistant_install:
pip.installed:
@@ -20,6 +28,7 @@ home_assistant_install:
{%- else %}
- name: homeassistant{%- if server.get('source', {}).version is defined %}=={{ server.source.version }}{%- endif %}
{%- endif %}
- user: home_assistant
- pre_releases: True
- bin_env: {{ server.dir.base }}
- exists_action: w
@@ -27,14 +36,6 @@ home_assistant_install:
- virtualenv: {{ server.dir.base }}
- pkg: home_assistant_packages

home_assistant_user:
user.present:
- name: home_assistant
- system: true
- home: {{ server.dir.base }}
- require:
- virtualenv: {{ server.dir.base }}

home_assistant_dir:
file.directory:
- names:
@@ -51,24 +52,19 @@ home_assistant_dir:
home_assistant_config:
git.latest:
- name: {{ server.config.address }}
- user: home_assistant
- target: /etc/home_assistant
- rev: {{ server.config.revision|default(server.config.branch) }}
{%- if grains.saltversion >= "2015.8.0" %}
- branch: {{ server.config.branch|default(server.config.revision) }}
{%- endif %}
{%- if server.config.identity is defined %}
- identity: {{ server.config.identity }}
{%- endif %}
- force_reset: {{ server.config.force_reset|default(False) }}

{%- else %}

home_assistant_config_dir:
file.directory:
- name: /etc/home_assistant
- mode: 700
- makedirs: true
- user: home_assistant
- require:
- virtualenv: {{ server.dir.base }}

home_assistant_config:
file.managed:
- name: /etc/home_assistant/configuration.yaml
@@ -77,7 +73,7 @@ home_assistant_config:
- user: home_assistant
- mode: 600
- require:
- file: home_assistant_config_dir
- file: home_assistant_dir

{%- if server.known_device is defined %}


Yükleniyor…
İptal
Kaydet