#####################################
### someone's ansible provisioner ###
#####################################
# Part of: https://git.somenet.org/root/pub/somesible.git
# 2017-2025 by someone <someone@somenet.org>
#
---
- name: copy unit-status-mail unit file
  copy:
    src: "{{item}}"
    dest: "/etc/systemd/system/unit-status-mail@.service"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/unit-status-mail.service"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/unit-status-mail.service"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/unit-status-mail.service"
    - "default/unit-status-mail.service"


- name: copy systemd-unit-status-mail shell script
  copy:
    src: "{{item}}"
    dest: "/bin/systemd-unit-status-mail.sh"
    mode: 0755
    owner: "root"
    group: "root"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/systemd-unit-status-mail.sh"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/systemd-unit-status-mail.sh"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/systemd-unit-status-mail.sh"
    - "default/systemd-unit-status-mail.sh"


- name: reload systemd
  systemd:
    daemon_reload: yes
