Vendor Galaxy Roles and Collections
This commit is contained in:
parent
c1e1897cda
commit
2aed20393f
3553 changed files with 387444 additions and 2 deletions
|
|
@ -0,0 +1,19 @@
|
|||
homeassistant - Setup and manage Home Assistant
|
||||
|
||||
Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
This Ansible role is part of DebOps.
|
||||
|
||||
DebOps is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 3, as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
DebOps is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DebOps. If not, see https://www.gnu.org/licenses/.
|
||||
|
|
@ -0,0 +1,386 @@
|
|||
---
|
||||
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
|
||||
|
||||
# .. Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
# .. Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
# .. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# .. _homeassistant__ref_defaults:
|
||||
|
||||
# debops-contrib.homeassistant default variables [[[
|
||||
# ==================================================
|
||||
|
||||
# .. contents:: Sections
|
||||
# :local:
|
||||
#
|
||||
# .. include:: includes/all.rst
|
||||
|
||||
|
||||
# Packages and installation [[[
|
||||
# -----------------------------
|
||||
|
||||
# .. envvar:: homeassistant__base_packages [[[
|
||||
#
|
||||
# List of base packages to install.
|
||||
homeassistant__base_packages:
|
||||
- 'libffi-dev'
|
||||
- 'libssl-dev'
|
||||
- 'libjpeg-dev'
|
||||
- 'zlib1g-dev'
|
||||
- 'autoconf'
|
||||
- 'build-essential'
|
||||
- 'libopenjp2-7'
|
||||
- 'libtiff5'
|
||||
- '{{ "libturbojpeg"
|
||||
if (ansible_distribution == "Ubuntu")
|
||||
else "libturbojpeg0" }}'
|
||||
- 'tzdata'
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__packages [[[
|
||||
#
|
||||
# List of additional packages to install.
|
||||
homeassistant__packages: []
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__dependency_python_packages [[[
|
||||
#
|
||||
# List of Home Assistant Core dependency packages.
|
||||
# This refers to Debian system packages and not Python packages.
|
||||
homeassistant__dependency_python_packages:
|
||||
- 'python3-dev'
|
||||
- 'python3-venv'
|
||||
- 'python3-pip'
|
||||
- 'python3-virtualenv'
|
||||
- 'python3-requests'
|
||||
- 'python3-yaml'
|
||||
- 'python3-tz'
|
||||
- 'python3-jinja2'
|
||||
- 'python3-voluptuous'
|
||||
|
||||
- '{{ ["python3-aiohttp"]
|
||||
if (ansible_distribution_release not in ["trusty"])
|
||||
else [] }}'
|
||||
- '{{ ["python3-async-timeout"]
|
||||
if (ansible_distribution == "Debian" and ansible_distribution_major_version | int >= 9)
|
||||
else [] }}'
|
||||
- 'python3-chardet'
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__optional_python_packages [[[
|
||||
#
|
||||
# List of optional packages.
|
||||
# This refers to Debian system packages and not Python packages.
|
||||
homeassistant__optional_python_packages:
|
||||
- '{{ ["python3-colorlog"]
|
||||
if (ansible_distribution_release not in ["trusty"])
|
||||
else [] }}'
|
||||
- 'libffi-dev'
|
||||
- 'libssl-dev'
|
||||
- 'python3-crypto'
|
||||
- 'python3-cryptography'
|
||||
- 'python3-pyparsing'
|
||||
- 'python3-appdirs'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__combined_packages [[[
|
||||
#
|
||||
# List of all system packages which will be installed by the role.
|
||||
homeassistant__combined_packages: '{{ (homeassistant__base_packages
|
||||
+ homeassistant__packages
|
||||
+ (homeassistant__dependency_python_packages
|
||||
if (not homeassistant__virtualenv | bool)
|
||||
else [])
|
||||
+ (homeassistant__optional_python_packages
|
||||
if (not homeassistant__virtualenv | bool)
|
||||
else []))
|
||||
| unique | sort }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__deploy_state [[[
|
||||
#
|
||||
# What is the desired state which this role should achieve? Possible options:
|
||||
#
|
||||
# ``present``
|
||||
# Default. Ensure that Home Assistant is installed and configured as requested.
|
||||
#
|
||||
# ``absent``
|
||||
# Ensure that Home Assistant is uninstalled. Not fully supported yet.
|
||||
#
|
||||
homeassistant__deploy_state: 'present'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# FQDN and DNS addresses [[[
|
||||
# --------------------------
|
||||
|
||||
# .. envvar:: homeassistant__fqdn [[[
|
||||
#
|
||||
# The Fully Qualified Domain Name of the Home Assistant instance. This address is
|
||||
# used to configure the webserver frontend.
|
||||
homeassistant__fqdn: 'ha.{{ homeassistant__domain }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__domain [[[
|
||||
#
|
||||
# Domain that will be configured for the Home Assistant instance.
|
||||
homeassistant__domain: '{{ ansible_domain }}'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Reverse proxy configuration [[[
|
||||
# -------------------------------
|
||||
|
||||
# While Home Assistant provides it’s own authentication methods one might want
|
||||
# to enable multiple authentications after each other that are enforced by
|
||||
# different components (Security in Depth).
|
||||
# Also refer to
|
||||
# `RFC: Support subpath/subdir hosting for additional security`__.
|
||||
#
|
||||
# .. __: https://github.com/debops/debops/issues/1233
|
||||
|
||||
# .. envvar:: homeassistant__verify_client_certificate [[[
|
||||
#
|
||||
# Should a valid client certificate be required to access Home Assistant?
|
||||
homeassistant__verify_client_certificate: False
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__basic_auth [[[
|
||||
#
|
||||
# Enable or disable HTTP Basic Authentication in the webserver frontend.
|
||||
# Note that there is an unhandled issue that you might face when enabling this.
|
||||
# Ref: https://github.com/home-assistant/core/issues/6184
|
||||
homeassistant__basic_auth: False
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__basic_auth_realm [[[
|
||||
#
|
||||
# The HTTP Basic Auth realm used for Home Assistant.
|
||||
homeassistant__basic_auth_realm: 'Home Assistant'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__basic_auth_name [[[
|
||||
#
|
||||
# Name of the :command:`htpasswd` file stored in the
|
||||
# :file:`/etc/nginx/private/` directory which contains HTTP Basic Auth
|
||||
# credentials.
|
||||
homeassistant__basic_auth_name: 'homeassistant'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__basic_auth_users [[[
|
||||
#
|
||||
# List of user accounts which will be allowed access to Home Assistant.
|
||||
homeassistant__basic_auth_users: '{{ ansible_local.core.admin_users | d([]) }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__webserver_user [[[
|
||||
#
|
||||
# Name of the webserver user account which will be granted read only access to
|
||||
# the www directory outside of the Home Assistant configuration directory.
|
||||
homeassistant__webserver_user: '{{ ansible_local.nginx.user | d("www-data") }}'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Directory paths [[[
|
||||
# -------------------
|
||||
|
||||
# .. envvar:: homeassistant__home_path [[[
|
||||
#
|
||||
# The Home Assistant system account home directory.
|
||||
homeassistant__home_path: '{{ (ansible_local.fhs.home | d("/var/local"))
|
||||
+ "/" + homeassistant__user }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__virtualenv_path [[[
|
||||
#
|
||||
# Path to the virtualenv where Home Assistant will be installed.
|
||||
homeassistant__virtualenv_path: '{{ homeassistant__home_path + "/prod_venv" }}'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# System user and group [[[
|
||||
# -------------------------
|
||||
|
||||
# .. envvar:: homeassistant__user [[[
|
||||
#
|
||||
# System UNIX account under which Home Assistant is run.
|
||||
homeassistant__user: 'homeassistant'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__group [[[
|
||||
#
|
||||
# System UNIX group used by Home Assistant.
|
||||
homeassistant__group: 'homeassistant'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__groups [[[
|
||||
#
|
||||
# List of additional system groups of the system UNIX account.
|
||||
# The ``dialout`` group grants accesses to devices typically used for home
|
||||
# automation which can be found under :file:`/dev/ttyACM*` for example.
|
||||
# If you don’t use such devices, you can remove the group from the list.
|
||||
homeassistant__groups: [ 'dialout' ]
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__gecos [[[
|
||||
#
|
||||
# Contents of the GECOS field set for the Home Assistant account.
|
||||
homeassistant__gecos: 'Home Assistant'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__shell [[[
|
||||
#
|
||||
# The default shell set on the Home Assistant account.
|
||||
homeassistant__shell: '/usr/sbin/nologin'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Home Assistant sources and deployment [[[
|
||||
# -----------------------------------------
|
||||
|
||||
# .. envvar:: homeassistant__virtualenv [[[
|
||||
#
|
||||
# Should a Python virtualenv be created and used for Home Assistant deployment?
|
||||
# Virtualenv is currently the only supported way. Listing all dependencies here
|
||||
# has is too high maintenance and does not help much because Home Assistant
|
||||
# might install dependencies ad-hoc.
|
||||
homeassistant__virtualenv: True
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__release_channel [[[
|
||||
#
|
||||
# Which release channel should be installed?
|
||||
#
|
||||
# Choices:
|
||||
#
|
||||
# * ``release``: Latest release.
|
||||
# * ``develop``: Latest development version.
|
||||
#
|
||||
homeassistant__release_channel: 'release'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__git_repo [[[
|
||||
#
|
||||
# The URI of the Home Assistant git source repository.
|
||||
homeassistant__git_repo: 'https://github.com/home-assistant/home-assistant.git'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__git_version [[[
|
||||
#
|
||||
# The git branch or tag which will be installed.
|
||||
# Refer to the `releasing documentation
|
||||
# <https://home-assistant.io/developers/releasing/>`__ for details.
|
||||
homeassistant__git_version: '{{ "master" if (homeassistant__release_channel in ["release"]) else "dev" }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__git_dest [[[
|
||||
#
|
||||
# Path where the Home Assistant sources will be checked out (installation path).
|
||||
homeassistant__git_dest: '{{ homeassistant__home_path + "/home-assistant" }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__git_recursive [[[
|
||||
#
|
||||
# Should the git repository be cloned recursively?
|
||||
homeassistant__git_recursive: True
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__git_depth [[[
|
||||
#
|
||||
# To which depth should the git repository be cloned?
|
||||
# Default is to clone the whole repository.
|
||||
homeassistant__git_depth: '{{ omit }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__git_update [[[
|
||||
#
|
||||
# Should new revisions be retrieved from the origin repository?
|
||||
homeassistant__git_update: True
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__daemon_path [[[
|
||||
#
|
||||
# File path where the Home Assistant console script is located.
|
||||
homeassistant__daemon_path: '{{ (homeassistant__home_path + "/prod_venv/bin/hass")
|
||||
if (homeassistant__virtualenv | bool)
|
||||
else (homeassistant__home_path + "/.local/bin/hass") }}'
|
||||
# ]]]
|
||||
# ]]]
|
||||
# Configuration for other Ansible roles [[[
|
||||
# -----------------------------------------
|
||||
|
||||
# .. envvar:: homeassistant__nginx__dependent_upstreams [[[
|
||||
#
|
||||
# Configuration of the Home Assistant nginx upstream, used by the debops.nginx_
|
||||
# Ansible role.
|
||||
homeassistant__nginx__dependent_upstreams:
|
||||
|
||||
- name: 'homeassistant'
|
||||
type: 'default'
|
||||
state: '{{ "present" if (homeassistant__deploy_state == "present") else "absent" }}'
|
||||
enabled: True
|
||||
server: 'localhost:8123'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__nginx__dependent_htpasswd [[[
|
||||
#
|
||||
# HTTP Basic Auth password configuration for the :ref:`debops.nginx` Ansible
|
||||
# role.
|
||||
homeassistant__nginx__dependent_htpasswd:
|
||||
name: '{{ homeassistant__basic_auth_name }}'
|
||||
users: '{{ homeassistant__basic_auth_users }}'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: homeassistant__nginx__dependent_servers [[[
|
||||
#
|
||||
# Configuration of the Home Assistant nginx server, used by the debops.nginx_
|
||||
# Ansible role.
|
||||
homeassistant__nginx__dependent_servers:
|
||||
|
||||
- name: '{{ homeassistant__fqdn }}'
|
||||
filename: 'debops.homeassistant'
|
||||
by_role: 'debops-contrib.homeassistant'
|
||||
state: '{{ "present" if (homeassistant__deploy_state == "present") else "absent" }}'
|
||||
type: 'proxy'
|
||||
ssl_verify_client: '{{ homeassistant__verify_client_certificate | bool }}'
|
||||
auth_basic: '{{ homeassistant__basic_auth | bool }}'
|
||||
auth_basic_realm: '{{ homeassistant__basic_auth_realm }}'
|
||||
auth_basic_name: '{{ homeassistant__basic_auth_name }}'
|
||||
options: |
|
||||
proxy_buffering off;
|
||||
|
||||
location /local/ {
|
||||
autoindex off;
|
||||
alias {{ homeassistant__home_path }}/www/;
|
||||
}
|
||||
location /local_brands/ {
|
||||
rewrite /local_brands/(.*) /$1 break;
|
||||
|
||||
proxy_pass https://brands.home-assistant.io/;
|
||||
|
||||
proxy_set_header Host brands.home-assistant.io;
|
||||
proxy_ssl_verify on;
|
||||
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||
proxy_ssl_server_name on;
|
||||
|
||||
# Aggressively cache files on disk.
|
||||
proxy_buffering on;
|
||||
proxy_cache brands;
|
||||
# Exclude $scheme$proxy_host from key to ease testing with different proxy_pass.
|
||||
proxy_cache_key $request_uri;
|
||||
proxy_cache_lock on;
|
||||
|
||||
# This might end up serving place holder files for 6 months.
|
||||
# Ref: https://github.com/home-assistant/brands#caching
|
||||
proxy_cache_valid 6M;
|
||||
|
||||
proxy_cache_valid 404 60m;
|
||||
proxy_method GET;
|
||||
proxy_pass_request_body off;
|
||||
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
|
||||
proxy_cache_bypass $http_pragma;
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
}
|
||||
proxy_pass: 'http://homeassistant'
|
||||
proxy_options: |
|
||||
proxy_redirect http:// https://;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
|
||||
# ]]]
|
||||
# ]]]
|
||||
# ]]]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
.. Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
.. Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
.. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
.. include:: ../CHANGES.rst
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
.. Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
.. Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
.. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
.. literalinclude:: ../COPYRIGHT
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
.. Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
.. Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
.. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
.. _homeassistant__ref_getting_started:
|
||||
|
||||
Getting started
|
||||
===============
|
||||
|
||||
.. include:: includes/all.rst
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
|
||||
Example inventory
|
||||
-----------------
|
||||
|
||||
To setup and manage Home Assistant on a given host or set of hosts, they need to
|
||||
be added one of the ``[debops_service_homeassistant.*]`` Ansible groups in the
|
||||
inventory depending on your way of deployment:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[debops_service_homeassistant_nginx]
|
||||
hostname
|
||||
|
||||
Example playbook
|
||||
----------------
|
||||
|
||||
Ansible playbook that uses the ``debops-contrib.homeassistant`` role and does not
|
||||
setup a reverse proxy:
|
||||
|
||||
.. literalinclude:: playbooks/homeassistant-plain.yml
|
||||
:language: yaml
|
||||
:lines: 1,5-
|
||||
|
||||
Ansible playbook that uses the ``debops-contrib.homeassistant`` role together
|
||||
with debops.nginx_ as reverse proxy:
|
||||
|
||||
.. literalinclude:: playbooks/homeassistant-nginx.yml
|
||||
:language: yaml
|
||||
:lines: 1,5-
|
||||
|
||||
These playbooks are shipped with this role under
|
||||
:file:`./docs/playbooks/` from which you can symlink them to your
|
||||
playbook directory.
|
||||
In case you use multiple `DebOps Contrib`_ roles, consider using the
|
||||
`DebOps Contrib playbooks`_.
|
||||
|
||||
Hosting static files
|
||||
--------------------
|
||||
|
||||
`Home Assistant supports hosting static files`__. The role configures the
|
||||
webserver to serve those files directly. Same as Home Assistant, no
|
||||
authentication for static files is provided!
|
||||
|
||||
To avoid the risk of giving the webserver access the configuration directory
|
||||
under which the :file:`www` directory is normally stored, the role creates the
|
||||
:file:`www` directory one level above the configuration directory and creates a
|
||||
symlink where Home Assistant would read them to not break the application in
|
||||
any way.
|
||||
|
||||
.. __: https://www.home-assistant.io/integrations/http/#hosting-files
|
||||
|
||||
Ansible tags
|
||||
------------
|
||||
|
||||
You can use Ansible ``--tags`` or ``--skip-tags`` parameters to limit what
|
||||
tasks are performed during Ansible run. This can be used after a host was first
|
||||
configured to speed up playbook execution, when you are sure that most of the
|
||||
configuration is already in the desired state.
|
||||
|
||||
Available role tags:
|
||||
|
||||
``role::homeassistant``
|
||||
Main role tag, should be used in the playbook to execute all of the role
|
||||
tasks as well as role dependencies.
|
||||
|
||||
``role::homeassistant:pkgs``
|
||||
Tasks related to system package management like installing or
|
||||
removing packages.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
.. Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
.. Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
.. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
.. include:: includes/global.rst
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
.. Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
.. Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
.. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
.. _debops-contrib.homeassistant:
|
||||
|
||||
Ansible role: debops-contrib.homeassistant
|
||||
==========================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
introduction
|
||||
getting-started
|
||||
defaults
|
||||
copyright
|
||||
changelog
|
||||
|
||||
..
|
||||
Local Variables:
|
||||
mode: rst
|
||||
ispell-local-dictionary: "american"
|
||||
End:
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
.. Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
.. Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
.. SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
.. include:: includes/all.rst
|
||||
|
||||
The ``debops-contrib.homeassistant`` role allows you to setup and manage
|
||||
`Home Assistant <https://en.wikipedia.org/wiki/Home_Assistant>`_.
|
||||
Home Assistant is a home automation platform running on Python 3.
|
||||
It is able to track and control all devices at home and offer a platform for
|
||||
automating control.
|
||||
|
||||
|
||||
Installation
|
||||
~~~~~~~~~~~~
|
||||
|
||||
This role requires at least Ansible ``v2.2.2``. To install it, run:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
ansible-galaxy install debops-contrib.homeassistant
|
||||
|
||||
..
|
||||
Local Variables:
|
||||
mode: rst
|
||||
ispell-local-dictionary: "american"
|
||||
End:
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
# vim: foldmarker=[[[,]]]:foldmethod=marker
|
||||
|
||||
# Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
# Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
- name: Restart Home Assistant
|
||||
ansible.builtin.systemd:
|
||||
name: 'home-assistant'
|
||||
state: 'restarted'
|
||||
when: (ansible_distribution_release not in ["trusty"])
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
# Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
# Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# Ensure that custom Ansible plugins and modules included in the main DebOps
|
||||
# collection are available to roles in other collections.
|
||||
collections: [ 'debops.debops' ]
|
||||
|
||||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
|
||||
company: 'DebOps'
|
||||
author: 'Robin Schneider'
|
||||
description: 'Setup and manage Home Assistant'
|
||||
license: 'GPL-3.0-only'
|
||||
min_ansible_version: '2.2.2'
|
||||
|
||||
platforms:
|
||||
|
||||
- name: Debian
|
||||
versions:
|
||||
- bullseye
|
||||
|
||||
galaxy_tags:
|
||||
- automation
|
||||
- home
|
||||
- homeassistant
|
||||
- iot
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
---
|
||||
# vim: foldmarker=[[[,]]]:foldmethod=marker
|
||||
|
||||
# Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
# Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
- name: Ensure specified packages are in there desired state
|
||||
ansible.builtin.package:
|
||||
name: '{{ q("flattened", homeassistant__combined_packages) }}'
|
||||
when: (homeassistant__deploy_state == "present")
|
||||
register: homeassistant__register_packages
|
||||
until: homeassistant__register_packages is succeeded
|
||||
tags: [ 'role::homeassistant:pkgs' ]
|
||||
|
||||
# System user and group [[[
|
||||
- name: Create Home Assistant system group
|
||||
ansible.builtin.group:
|
||||
name: '{{ homeassistant__group }}'
|
||||
state: '{{ "present" if (homeassistant__deploy_state == "present") else "absent" }}'
|
||||
system: True
|
||||
|
||||
- name: Create Home Assistant system user
|
||||
ansible.builtin.user:
|
||||
name: '{{ homeassistant__user }}'
|
||||
group: '{{ homeassistant__group }}'
|
||||
groups: '{{ homeassistant__groups | join(",") | default(omit) }}'
|
||||
append: False
|
||||
home: '{{ homeassistant__home_path }}'
|
||||
comment: '{{ homeassistant__gecos }}'
|
||||
shell: '{{ homeassistant__shell }}'
|
||||
state: '{{ "present" if (homeassistant__deploy_state == "present") else "absent" }}'
|
||||
system: True
|
||||
# ]]]
|
||||
|
||||
- name: Clone Home Assistant git repository
|
||||
ansible.builtin.git:
|
||||
repo: '{{ homeassistant__git_repo }}'
|
||||
dest: '{{ homeassistant__git_dest }}'
|
||||
depth: '{{ homeassistant__git_depth }}'
|
||||
version: '{{ homeassistant__git_version }}'
|
||||
recursive: '{{ homeassistant__git_recursive | bool }}'
|
||||
update: '{{ homeassistant__git_update | bool }}'
|
||||
become: True
|
||||
become_user: '{{ homeassistant__user }}'
|
||||
register: homeassistant__register_git
|
||||
when: (homeassistant__deploy_state == "present")
|
||||
|
||||
- name: Install hass without virtualenv
|
||||
ansible.builtin.pip: # noqa no-handler
|
||||
name: '.'
|
||||
chdir: '{{ homeassistant__git_dest }}'
|
||||
executable: 'pip3'
|
||||
extra_args: '--user --upgrade'
|
||||
become: True
|
||||
become_user: '{{ homeassistant__user }}'
|
||||
when: not homeassistant__virtualenv | bool and homeassistant__register_git is changed
|
||||
notify: [ 'Restart Home Assistant' ]
|
||||
|
||||
- name: Install hass in virtualenv
|
||||
ansible.builtin.pip: # noqa no-handler
|
||||
name: '.'
|
||||
chdir: '{{ homeassistant__git_dest }}'
|
||||
extra_args: '--upgrade'
|
||||
virtualenv: '{{ homeassistant__virtualenv_path }}'
|
||||
virtualenv_python: 'python3'
|
||||
become: True
|
||||
become_user: '{{ homeassistant__user }}'
|
||||
when: homeassistant__virtualenv | bool and homeassistant__register_git is changed
|
||||
notify: [ 'Restart Home Assistant' ]
|
||||
|
||||
# https://community.home-assistant.io/t/wth-why-are-brand-icons-a-cloud-dependency/226359/13
|
||||
# Does not work. Home assistant still requests the files from https://brands.home-assistant.io/ …
|
||||
# - name: Change hardcoded brands.home-assistant.io domain and point to Nginx
|
||||
# ansible.builtin.shell: |
|
||||
# set -o pipefail -o errexit;
|
||||
# for i in $(find lib/python*/site-packages/hass_frontend/ lib/python*/site-packages/homeassistant/components/ -iname '*.js.gz' -type f); do zcat "$i" | sed --regexp-extended 's#https://brands\.home-assistant\.io/#https://{{ homeassistant__fqdn }}/local_brands/brands/#g;s#brands\.home-assistant\.io#{{ homeassistant__fqdn }}#g;' > "$i.copy"; gzip "$i.copy"; mv "$i.copy.gz" "$i" ; done
|
||||
# find lib/python*/site-packages/hass_frontend/ lib/python*/site-packages/homeassistant/components/ -not -iname '*.gz' -type f -print0 | xargs --null sed --in-place --regexp-extended 's#https://brands\.home-assistant\.io/#https://{{ homeassistant__fqdn }}/local_brands/brands/#g;s#brands\.home-assistant\.io#{{ homeassistant__fqdn }}#g;'
|
||||
# args:
|
||||
# chdir: '{{ homeassistant__virtualenv_path }}'
|
||||
# executable: 'bash'
|
||||
# become: True
|
||||
# become_user: '{{ homeassistant__user }}'
|
||||
# when: homeassistant__register_git is changed
|
||||
|
||||
- name: Ensure Home Assistant config dir exists
|
||||
ansible.builtin.file:
|
||||
path: '{{ homeassistant__home_path }}/.homeassistant'
|
||||
mode: '0750'
|
||||
state: 'directory'
|
||||
become: True
|
||||
become_user: '{{ homeassistant__user }}'
|
||||
when: (homeassistant__deploy_state == "present")
|
||||
|
||||
- name: Ensure Home Assistant www dir exists
|
||||
ansible.builtin.file:
|
||||
path: '{{ homeassistant__home_path }}/www'
|
||||
owner: '{{ homeassistant__user }}'
|
||||
group: '{{ homeassistant__webserver_user }}'
|
||||
mode: '0750'
|
||||
state: 'directory'
|
||||
when: (homeassistant__deploy_state == "present")
|
||||
|
||||
- name: Ensure Home Assistant www in config dir is a symlink
|
||||
ansible.builtin.file:
|
||||
src: '{{ homeassistant__home_path }}/www'
|
||||
dest: '{{ homeassistant__home_path }}/.homeassistant/www'
|
||||
state: 'link'
|
||||
mode: '0755'
|
||||
become: True
|
||||
become_user: '{{ homeassistant__user }}'
|
||||
when: (homeassistant__deploy_state == "present")
|
||||
|
||||
- name: Configure systemd unit file
|
||||
ansible.builtin.template:
|
||||
src: 'etc/systemd/system/home-assistant.service.j2'
|
||||
dest: '/etc/systemd/system/home-assistant.service'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
register: homeassistant__register_systemd_unit_file
|
||||
when: (homeassistant__deploy_state == "present")
|
||||
|
||||
- name: Set Home Assistant state using systemd
|
||||
ansible.builtin.systemd:
|
||||
name: 'home-assistant'
|
||||
state: '{{ "started" if (homeassistant__deploy_state == "present") else "stopped" }}'
|
||||
enabled: True
|
||||
masked: False
|
||||
daemon_reload: '{{ homeassistant__register_systemd_unit_file is changed }}'
|
||||
when: (homeassistant__deploy_state == "present" and ansible_distribution_release not in ["trusty"])
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
# vim: foldmarker=[[[,]]]:foldmethod=marker
|
||||
|
||||
# Copyright (C) 2022 Robin Schneider <ypid@riseup.net>
|
||||
# Copyright (C) 2022 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# - name: Ensure Nginx cache dir exists
|
||||
# ansible.builtin.file:
|
||||
# path: '/var/cache/nginx/proxy'
|
||||
# mode: '0700'
|
||||
# state: 'directory'
|
||||
# owner: 'www-data'
|
||||
# group: 'root'
|
||||
# when: (homeassistant__deploy_state == "present")
|
||||
|
||||
# - name: Configure Nginx proxy_cache_path
|
||||
# ansible.builtin.template:
|
||||
# src: 'etc/nginx/conf.d/debops.homeassistant.conf.j2'
|
||||
# dest: '/etc/nginx/conf.d/debops.homeassistant.conf'
|
||||
# owner: 'root'
|
||||
# group: 'root'
|
||||
# mode: '0644'
|
||||
# when: (homeassistant__deploy_state == "present")
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{# Copyright (C) 2022 Robin Schneider <ypid@riseup.net>
|
||||
# Copyright (C) 2022 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#}
|
||||
# {{ ansible_managed }}
|
||||
|
||||
proxy_cache_path /var/cache/nginx/proxy levels=1:2 keys_zone=brands:10m use_temp_path=off inactive=5y max_size=5g;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{# Copyright (C) 2017 Robin Schneider <ypid@riseup.net>
|
||||
# Copyright (C) 2017 DebOps <https://debops.org/>
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#}
|
||||
# {{ ansible_managed }}
|
||||
# Source: https://home-assistant.io/docs/autostart/systemd/
|
||||
|
||||
[Unit]
|
||||
Description=Home Assistant
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{ homeassistant__user }}
|
||||
ExecStart={{ homeassistant__daemon_path }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Reference in a new issue