logrotate with path testing #1

Closed
opened 2020-08-21 06:22:32 +00:00 by reelsense · 1 comment
reelsense commented 2020-08-21 06:22:32 +00:00 (Migrated from github.com)

Description

I need a logrotate role that can test if paths exist before writing a logrotate config to the server. I want to load the roles default vars with custom paths and per path parameters, so I can run the playbook across a dynamic infrastructure and only write logerotate rules to the appropriate system with the correct paths present.

The ansible-galaxy role that was immediately intuitive to me was weareinteractive/ansible-logrotate. If you find another role and you think that will do what I wan't let me know. Otherwise I need to modify an existing role.

Example

Based on weareinteractive/ansible-logrotate; Here is an example of what I imagine I would put in defaults/main.yml.

 logrotate_scripts:
#   - name: nginx
#     path: /var/log/nginx/*.log
#     options:
#       - daily
#       - compress
#       - rotate 6
#       - missingok
#       - copytruncate
#       - delaycompress
#     scripts:
#       postrotate: "[ -s /run/nginx.pid ] && kill USR1 `cat /run/nginx.pid`"

   - name: 'nextcloud snap apache php_errors'
     path: /var/snap/nextcloud/current/apache/logs/*.log
     options:
       - daily
       - compress
       - rotate 6
       - missingok
       - copytruncate
       - delaycompress

   - name: nextcloud snap apache error_log
     path: /var/snap/nextcloud/current/apache/logs/error_log
     options:
       - daily
       - compress
       - rotate 6
       - missingok
       - copytruncate
       - delaycompress

   - name: custom
     path: /var/log/custom/*_log
     options:
       - daily
       - compress
       - rotate 6

If I'm remembering correctly, the last time I tried this with weareinteractive/ansible-logrotate I ended up creating nextcloud log rotation rules on systems that don't have those directories.



x-post: https://github.com/stationgroup/ansible-logrotate-plusplus/pull/2

## Description I need a logrotate role that can test if paths exist before writing a logrotate config to the server. I want to load the roles default vars with custom paths and per path parameters, so I can run the playbook across a dynamic infrastructure and only write logerotate rules to the appropriate system with the correct paths present. The ansible-galaxy role that was immediately intuitive to me was [weareinteractive/ansible-logrotate](https://github.com/weareinteractive/ansible-logrotate). If you find another role and you think that will do what I wan't let me know. Otherwise I need to modify an existing role. ## Example Based on [weareinteractive/ansible-logrotate](https://github.com/weareinteractive/ansible-logrotate); Here is an example of what I imagine I would put in `defaults/main.yml`. ```yaml logrotate_scripts: # - name: nginx # path: /var/log/nginx/*.log # options: # - daily # - compress # - rotate 6 # - missingok # - copytruncate # - delaycompress # scripts: # postrotate: "[ -s /run/nginx.pid ] && kill USR1 `cat /run/nginx.pid`" - name: 'nextcloud snap apache php_errors' path: /var/snap/nextcloud/current/apache/logs/*.log options: - daily - compress - rotate 6 - missingok - copytruncate - delaycompress - name: nextcloud snap apache error_log path: /var/snap/nextcloud/current/apache/logs/error_log options: - daily - compress - rotate 6 - missingok - copytruncate - delaycompress - name: custom path: /var/log/custom/*_log options: - daily - compress - rotate 6 ``` If I'm remembering correctly, the last time I tried this with [weareinteractive/ansible-logrotate](https://github.com/weareinteractive/ansible-logrotate) I ended up creating nextcloud log rotation rules on systems that don't have those directories. --- --- x-post: https://github.com/stationgroup/ansible-logrotate-plusplus/pull/2
srgvg commented 2020-08-25 17:24:39 +00:00 (Migrated from github.com)
Two other suiting roles: * https://github.com/arillso/ansible.logrotate * https://github.com/robertdebock/ansible-role-logrotate
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: stationgroup/ansible-logrotate-plusplus#1
No description provided.