Vendor Galaxy Roles and Collections
Some checks failed
/ Ansible Lint (push) Failing after 5m45s
/ Ansible Lint (pull_request) Failing after 4m59s

This commit is contained in:
Stefan Bethke 2026-02-06 22:07:16 +01:00
commit 2aed20393f
3553 changed files with 387444 additions and 2 deletions

View file

@ -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"])

View file

@ -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")