Saltstack Official Home Assistant Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

server.sls 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_install:
  14. pip.installed:
  15. {%- if server.source is defined and server.source.get("engine", "git") %}
  16. - editable: git+{{ server.source.address }}@{{ server.source.version }}#egg=homeassistant
  17. {%- else %}
  18. - name: homeassistant{%- if server.get('source', {}).version is defined %}=={{ server.source.version }}{%- endif %}
  19. {%- endif %}
  20. - pre_releases: True
  21. - bin_env: {{ server.dir.base }}
  22. - exists_action: w
  23. - require:
  24. - virtualenv: {{ server.dir.base }}
  25. - pkg: home_assistant_packages
  26. home_assistant_user:
  27. user.present:
  28. - name: home_assistant
  29. - system: true
  30. - home: {{ server.dir.base }}
  31. - require:
  32. - virtualenv: {{ server.dir.base }}
  33. home_assistant_dir:
  34. file.directory:
  35. - names:
  36. - /etc/home_assistant
  37. - /var/log/home_assistant
  38. - mode: 700
  39. - makedirs: true
  40. - user: home_assistant
  41. - require:
  42. - virtualenv: {{ server.dir.base }}
  43. {%- if server.config.engine == 'git' %}
  44. home_assistant_config:
  45. git.latest:
  46. - name: {{ server.config.address }}
  47. - target: /etc/home_assistant
  48. - rev: {{ server.config.revision|default(server.config.branch) }}
  49. {%- if grains.saltversion >= "2015.8.0" %}
  50. - branch: {{ server.config.branch|default(server.config.revision) }}
  51. {%- endif %}
  52. - force_reset: {{ server.config.force_reset|default(False) }}
  53. {%- else %}
  54. home_assistant_config_dir:
  55. file.directory:
  56. - name: /etc/home_assistant
  57. - mode: 700
  58. - makedirs: true
  59. - user: home_assistant
  60. - require:
  61. - virtualenv: {{ server.dir.base }}
  62. home_assistant_config:
  63. file.managed:
  64. - name: /etc/home_assistant/configuration.yaml
  65. - source: salt://home_assistant/files/configuration.yaml
  66. - template: jinja
  67. - user: home_assistant
  68. - mode: 600
  69. - require:
  70. - file: home_assistant_config_dir
  71. {%- if server.known_device is defined %}
  72. home_assistant_know_devices:
  73. file.managed:
  74. - name: /etc/home_assistant/known_devices.yaml
  75. - source: salt://home_assistant/files/known_devices.yaml
  76. - template: jinja
  77. - user: home_assistant
  78. - mode: 600
  79. - require:
  80. - file: home_assistant_dir
  81. {%- endif %}
  82. {%- endif %}
  83. {%- endif %}