Skip to content

Commit

Permalink
Test more and in the approriate location.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdebock committed Mar 26, 2019
1 parent b73fd86 commit 739ab11
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ This example is taken from `molecule/default/playbook.yml`:
become: yes
gather_facts: yes

vars:
logrotate_frequency: daily
logrotate_keep: 7
logrotate_compress: yes
logrotate_entries:
- name: example
path: "/var/log/example/*.log"
- name: example-frequency
path: "/var/log/example-frequency/*.log"
frequency: weekly
- name: example-keep
path: "/var/log/example-keep/*.log"
keep: 14
- name: example-compress-yes
path: "/var/log/example-compress/*.log"
compress: yes
- name: example-compress-no
path: "/var/log/example-compress/*.log"
compress: no

roles:
- robertdebock.logrotate
```
Expand Down Expand Up @@ -50,13 +70,6 @@ logrotate_keep: 4
# Should rotated logs be compressed??
logrotate_compress: yes
logrotate_entries:
- name: example
path: "/var/log/example/*.log"
frequency: daily
keep: 7
compress: no
```

Requirements
Expand Down
7 changes: 0 additions & 7 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ logrotate_keep: 4

# Should rotated logs be compressed??
logrotate_compress: yes

logrotate_entries:
- name: example
path: "/var/log/example/*.log"
frequency: daily
keep: 7
compress: no
20 changes: 20 additions & 0 deletions molecule/resources/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,25 @@
become: yes
gather_facts: yes

vars:
logrotate_frequency: daily
logrotate_keep: 7
logrotate_compress: yes
logrotate_entries:
- name: example
path: "/var/log/example/*.log"
- name: example-frequency
path: "/var/log/example-frequency/*.log"
frequency: weekly
- name: example-keep
path: "/var/log/example-keep/*.log"
keep: 14
- name: example-compress-yes
path: "/var/log/example-compress/*.log"
compress: yes
- name: example-compress-no
path: "/var/log/example-compress/*.log"
compress: no

roles:
- ansible-role-logrotate
7 changes: 4 additions & 3 deletions templates/entry.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{{ ansible_managed | comment }}

{{ item.path }} {
{{ item.frequency | default(omit) }}
{% if item.compress %} compress{% endif %}
{{ item.keep | default(omit) }}
{% if item.frequency is defined %} {{ item.frequency }}{% endif %}
{% if item.compress is defined %}{% if item.compress %} compress{% endif %}{% endif %}
{% if item.keep is defined %} rotate {{ item.keep }}{% endif %}

}

0 comments on commit 739ab11

Please sign in to comment.