---
# main tasks for rsyslog config

- debug: var=rsyslog

- name: add packages
  apt:
    state: present
    name: "{{item}}"
    update_cache: yes
    cache_valid_time: 86400
  with_items:
    - rsyslog-gnutls

- name: copy tls certs for papertrail
  get_url:
    url: https://papertrailapp.com/tools/papertrail-bundle.pem
    dest: /etc/papertrail-bundle.pem
    force: yes
    mode: 0644

- name: copy custom configs
  template:
    src: "{{ item }}.j2"
    dest: /etc/rsyslog.d/{{ item }}.conf
    owner: "{{ rsyslog.user }}"
    group: "{{ rsyslog.group }}"
    mode: 0644
  with_items: "{{rsyslog.configs}}"
  notify:
    - restart rsyslog
