Browse Source

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 years ago
parent
commit
dda3625ae7
2 changed files with 15 additions and 18 deletions
  1. +1
    -0
      README.rst
  2. +14
    -18
      home_assistant/server.sls

+ 1
- 0
README.rst View File

engine: git engine: git
address: '${_param:home_assistant_config_repository}' address: '${_param:home_assistant_config_repository}'
branch: ${_param:home_assistant_config_revision} branch: ${_param:home_assistant_config_revision}
identity: /path/to/optional/ssh/identity/file




References References

+ 14
- 18
home_assistant/server.sls View File

pkg.installed: pkg.installed:
- names: {{ server.pkgs }} - names: {{ server.pkgs }}


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

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


home_assistant_install: home_assistant_install:
pip.installed: pip.installed:
{%- else %} {%- else %}
- name: homeassistant{%- if server.get('source', {}).version is defined %}=={{ server.source.version }}{%- endif %} - name: homeassistant{%- if server.get('source', {}).version is defined %}=={{ server.source.version }}{%- endif %}
{%- endif %} {%- endif %}
- user: home_assistant
- pre_releases: True - pre_releases: True
- bin_env: {{ server.dir.base }} - bin_env: {{ server.dir.base }}
- exists_action: w - exists_action: w
- virtualenv: {{ server.dir.base }} - virtualenv: {{ server.dir.base }}
- pkg: home_assistant_packages - 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: home_assistant_dir:
file.directory: file.directory:
- names: - names:
home_assistant_config: home_assistant_config:
git.latest: git.latest:
- name: {{ server.config.address }} - name: {{ server.config.address }}
- user: home_assistant
- target: /etc/home_assistant - target: /etc/home_assistant
- rev: {{ server.config.revision|default(server.config.branch) }} - rev: {{ server.config.revision|default(server.config.branch) }}
{%- if grains.saltversion >= "2015.8.0" %} {%- if grains.saltversion >= "2015.8.0" %}
- branch: {{ server.config.branch|default(server.config.revision) }} - branch: {{ server.config.branch|default(server.config.revision) }}
{%- endif %} {%- endif %}
{%- if server.config.identity is defined %}
- identity: {{ server.config.identity }}
{%- endif %}
- force_reset: {{ server.config.force_reset|default(False) }} - force_reset: {{ server.config.force_reset|default(False) }}


{%- else %} {%- 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: home_assistant_config:
file.managed: file.managed:
- name: /etc/home_assistant/configuration.yaml - name: /etc/home_assistant/configuration.yaml
- user: home_assistant - user: home_assistant
- mode: 600 - mode: 600
- require: - require:
- file: home_assistant_config_dir
- file: home_assistant_dir


{%- if server.known_device is defined %} {%- if server.known_device is defined %}



Loading…
Cancel
Save