- name: "syslog: create /usr/local/etc/syslog.d/"
  file:
    path: /usr/local/etc/syslog.d/
    state: directory
    owner: root
    group: wheel
    mode: "0755"

- name: "syslog: remove obsolete syslog files"
  file:
    path: "{{ item }}"
    state: absent
  loop:
    - /usr/local/etc/syslog.d/console.conf
  notify: restart_syslogd

- name: "syslog: install syslog.d files"
  copy:
    src: "{{ item }}"
    dest: /usr/local/etc/syslog.d/
    owner: root
    group: wheel
    mode: "0644"
  with_fileglob:
    - ../ansible/syslog.d/*.conf
  notify: restart_syslogd

- name: "syslog: touch log files"
  file:
    path: "/var/log/{{ item }}"
    state: touch
    mode: "0600"
  changed_when: no
  loop:
    - console.log

- name: "syslog: disable '/dev/console' target in /etc/syslog.conf"
  replace:
    path: /etc/syslog.conf
    regexp: '([^#].*/dev/console$)'
    replace: '#\1'
  notify: restart_syslogd

- name: "syslog: create /usr/local/etc/syslog.d/"
  file:
    path: /usr/local/etc/syslog.d/
    state: directory
    owner: root
    group: wheel
    mode: "0755"

- name: "syslog: remove obsolete syslog files"
  file:
    path: "{{ item }}"
    state: absent
  loop:
    - /usr/local/etc/syslog.d/console.conf
  notify: restart_syslogd

- name: "syslog: install syslog.d files"
  copy:
    src: "{{ item }}"
    dest: /usr/local/etc/syslog.d/
    owner: root
    group: wheel
    mode: "0644"
  with_fileglob:
    - ../ansible/syslog.d/*.conf
  notify: restart_syslogd

- name: "syslog: touch log files"
  file:
    path: "/var/log/{{ item }}"
    state: touch
    mode: "0600"
  changed_when: no
  loop:
    - console.log

- name: "syslog: disable '/dev/console' target in /etc/syslog.conf"
  replace:
    path: /etc/syslog.conf
    regexp: '^([^#].*/dev/console$)'
    replace: '#\1'
  notify: restart_syslogd

Fix regexp for disabling '/dev/console' in '/etc/syslog.conf'.
Fix regexp for disabling '/dev/console' in '/etc/syslog.conf'.
