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


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


- name: copy syslog logrotate config
  copy:
    src: "{{item}}"
    dest: "/etc/logrotate.d/rsyslog"
    mode: 0644
    owner: "root"
    group: "root"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/d.rsyslog"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/d.rsyslog"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/d.rsyslog"
    - "default/d.rsyslog"


- name: enable and start logrotate.timer
  include_role: name="base/systemd/enable-and-start"
  vars:
    service_name: logrotate.timer
