Initial commit
This commit is contained in:
commit
3f30a4bef3
4 changed files with 191 additions and 0 deletions
63
tasks/main.yml
Normal file
63
tasks/main.yml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
- name: install syslog-ng package (alpine)
|
||||
apk:
|
||||
name:
|
||||
- syslog-ng
|
||||
- logrotate
|
||||
state: present
|
||||
update_cache: yes
|
||||
when: ansible_distribution == 'Alpine'
|
||||
|
||||
- name: remove rsyslog package (debian)
|
||||
apt:
|
||||
name:
|
||||
- rsyslog
|
||||
state: absent
|
||||
when: ansible_distribution == 'Debian'
|
||||
|
||||
- name: install syslog-ng package (debian)
|
||||
apt:
|
||||
name:
|
||||
- syslog-ng
|
||||
- logrotate
|
||||
state: present
|
||||
update_cache: yes
|
||||
when: ansible_distribution == 'Debian'
|
||||
|
||||
- name: Copy syslog configuration
|
||||
template:
|
||||
src: syslog-ng.conf.j2
|
||||
dest: /etc/syslog-ng/syslog-ng.conf
|
||||
mode: u+rw,g+r,o+r
|
||||
notify:
|
||||
- reload syslog
|
||||
|
||||
- name: configure logrotate
|
||||
lineinfile:
|
||||
path: /etc/logrotate.conf
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
with_items:
|
||||
- { regexp: "^#?/var/log/messages {}", line: "#/var/log/messages {}" }
|
||||
- { regexp: "^(daily|weekly|monthly|yearly)", line: "weekly" }
|
||||
- { regexp: "^(size|maxsize).*", line: "maxsize 512M" }
|
||||
|
||||
- name: ensure syslog is disabled
|
||||
service:
|
||||
name: syslog
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: ansible_distribution == 'Alpine'
|
||||
|
||||
- name: "ensure destination directory exists on {{ item }}"
|
||||
file:
|
||||
path: "/var/log/{{ inventory_hostname }}"
|
||||
state: directory
|
||||
delegate_to: "{{ item }}"
|
||||
with_items: "{{ log_hosts }}"
|
||||
|
||||
- name: ensure syslog-ng is enabled
|
||||
service:
|
||||
name: syslog-ng
|
||||
enabled: yes
|
||||
state: started
|
||||
Loading…
Add table
Add a link
Reference in a new issue