infra/roles/hass-utils/tasks/hass-utils.yml

64 lines
1.4 KiB
YAML

---
- name: create dir structure
file:
path: "{{ systemuserlist.hass.home }}/{{ item.name }}"
state: directory
mode: "{{ item.mode | default('0755') }}"
owner: hass
group: hass
tags:
- hass-dirs
- hass-utils-dirs
loop_control:
label: "{{ item.name }}"
with_items:
- name: utils
- name: utils/config
- name: install venv for scripts
pip:
name:
- pip
- pyyaml
- loguru
- requests
# lets just use the ansible task to update the virtualenv
state: latest
virtualenv: "{{ systemuserlist.hass.home }}/.cache/virtualenvs/scripts"
virtualenv_site_packages: false
virtualenv_command: python3 -m venv
become_user: hass
when: not ansible_check_mode
tags:
- hass-esphome-virtualenv
- esphome-virtualenv
- name: copy scripts
copy:
src: "{{ item }}"
dest: "{{ systemuserlist.hass.home }}/.cache/virtualenvs/scripts/bin/{{ item }}"
mode: "0755"
owner: hass
group: hass
tags:
- scripts
loop_control:
label: "{{ item }}"
with_items:
- valetudoctl.py
- clean_known_devices.py
- name: template configs
template:
src: "{{ item }}.j2"
dest: "{{ systemuserlist.hass.home }}/utils/config/{{ item }}"
owner: "{{ systemuserlist.hass.uid }}"
group: "{{ systemuserlist.hass.gid }}"
mode: 0644
with_items:
- valetudo.json
tags:
- hass-utils
- hass-utils-config