Anyone use Ansible to deploy/maintain Homeassistant?
TL;DR - I can start/stop my homeassistant service when logged in, but when I use Ansible’s service (or systemd) module, I get a permission denied error if I’m trying to start HA if it’s stopped or stop HA when it’s started. Starting when its started or stopping when it’s stopped works, but of course, doesn’t help things.
I’m not sure whether this is a HA issue, Ansible, or systemd issue. If I’m logged in as the homeassistant user, I can start/stop homeassistant service just fine.
sudo systemctl stop home-assistant@homeassistant
I configured the user (in /etc/sudoers.d) to not require a password when the start/stop/restart call is made by the homeassistant user.
However, if I use Ansible, I get an issue where Ansible only receives a success when the state doesn’t change (i.e., starting when HA is running or stopping when HA is stopped). Any attempt to start when it’s stopped or stop when it’s started fails with a permission denied error. And in fact, in verbose mode, Ansible shows that it’s just reporting that from further down the stack, like maybe systemd. The payload that Ansible makes is the same. The result of that call is the only thing that’s different.
This is my homeassistant systemd unit file:
[Unit]
Description=Home Assistant
After=network.target
[Service]
Type=simple
User=homeassistant
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c "/home/homeassistant/.homeassistant"
[Install]
WantedBy=multi-user.target
Journalctl does not show anything when I launch via ansible-playbook. However, in /var/log/messages, I see this:
Jun 11 00:08:53 192.168.1.10 ansible-systemd: Invoked with no_block=False name= enabled=True daemon_reload=False state=started user=False masked=None
Jun 11 00:09:02 192.168.1.10 ansible-setup: Invoked with filter=* gather_subset=['all'] fact_path=/etc/ansible/facts.d gather_timeout=10
I’m wondering if that home assistant user is not getting to the systemd call.
I asked this question on Stackoverflow, but haven’t gotten a solid response about it. Anyone here know what’s going on?