#####################################
### someone's ansible provisioner ###
#####################################
# Part of: https://git.somenet.org/root/pub/somesible.git
# 2017-2026 by someone <someone@somenet.org>
#
---
- name: "setup enabling preset for {{ service_name }}"
  template:
    src: "{{item}}"
    dest: "/etc/systemd/system-preset/10-somesible-{{ service_name }}.preset"
    mode: 0644
    owner: "root"
    group: "root"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/10-somesible-service.preset.j2"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/10-somesible-service.preset.j2"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/10-somesible-service.preset.j2"
    - "templates/10-somesible-service.preset.j2"
  when: not '@' in service_name
  tags: ['systemd', 'systemd-enable-and-start']


- name: "enable and start {{ service_name }}"
  systemd:
    name: "{{ service_name }}"
    daemon_reload: yes
    enabled: yes
    state: "{{ service_state }}"
  tags: ['systemd', 'systemd-enable-and-start']
  ignore_errors: yes
