#####################################
### someone's ansible provisioner ###
#####################################
# Part of: https://git.somenet.org/root/pub/somesible.git
# 2017-2026 by someone <someone@somenet.org>
#
---
- name: install saslauthd
  apt:
    pkg:
    - sasl2-bin
    state: present
    policy_rc_d: 101
  tags: "online"
  ignore_errors: "{{ignore_online_errors | bool}}"


- name: copy saslauthd defaults
  copy:
    src: "{{item}}"
    dest: "/etc/default/saslauthd"
    mode: 0644
    owner: "root"
    group: "root"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/saslauthd.defaults"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/saslauthd.defaults"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/saslauthd.defaults"
    - "default/saslauthd.defaults"
  notify: restart saslauthd.service


- name: copy saslauthd.conf
  copy:
    src: "{{item}}"
    dest: "/etc/saslauthd.conf"
    mode: 0644
    owner: "root"
    group: "root"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/saslauthd.conf"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/saslauthd.conf"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/saslauthd.conf"
    - "default/saslauthd.conf"
  notify: restart saslauthd.service


- name: enable and start saslauthd.service
  include_role: name="base/systemd/enable-and-start"
  vars:
    service_name: saslauthd.service
