Saltstack Official Home Assistant Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 line
1.9KB

  1. {%- from "home_assistant/map.jinja" import server with context %}
  2. {%- if server.enabled %}
  3. home_assistant_packages:
  4. pkg.installed:
  5. - names: {{ server.pkgs }}
  6. {{ server.dir.base }}:
  7. virtualenv.manage:
  8. - system_site_packages: True
  9. - requirements: salt://home_assistant/files/requirements.txt
  10. - python: /usr/bin/python3
  11. - require:
  12. - pkg: home_assistant_packages
  13. home_assistant_user:
  14. user.present:
  15. - name: home_assistant
  16. - system: true
  17. - home: {{ server.dir.base }}
  18. - require:
  19. - virtualenv: {{ server.dir.base }}
  20. home_assistant_dir:
  21. file.directory:
  22. - names:
  23. - /etc/home_assistant
  24. - /var/log/home_assistant
  25. - mode: 700
  26. - makedirs: true
  27. - user: home_assistant
  28. - require:
  29. - virtualenv: {{ server.dir.base }}
  30. {%- if server.config.engine == 'git' %}
  31. home_assistant_config:
  32. git.latest:
  33. - name: {{ server.config.address }}
  34. - target: /etc/home_assistant
  35. - rev: {{ server.config.revision|default(server.config.branch) }}
  36. {%- if grains.saltversion >= "2015.8.0" %}
  37. - branch: {{ server.config.branch|default(server.config.revision) }}
  38. {%- endif %}
  39. - force_reset: {{ server.config.force_reset|default(False) }}
  40. {%- else %}
  41. home_assistant_config_dir:
  42. file.directory:
  43. - name: /etc/home_assistant
  44. - mode: 700
  45. - makedirs: true
  46. - user: home_assistant
  47. - require:
  48. - virtualenv: {{ server.dir.base }}
  49. home_assistant_config:
  50. file.managed:
  51. - name: /etc/home_assistant/configuration.yaml
  52. - source: salt://home_assistant/files/configuration.yaml
  53. - template: jinja
  54. - user: home_assistant
  55. - mode: 600
  56. - require:
  57. - file: home_assistant_config_dir
  58. {%- if server.known_device is defined %}
  59. home_assistant_know_devices:
  60. file.managed:
  61. - name: /etc/home_assistant/known_devices.yaml
  62. - source: salt://home_assistant/files/known_devices.yaml
  63. - template: jinja
  64. - user: home_assistant
  65. - mode: 600
  66. - require:
  67. - file: home_assistant_dir
  68. {%- endif %}
  69. {%- endif %}
  70. {%- endif %}