Add check to deploy config if log exists
Role will now test if a log exist (and hence the application exists on the host before writing a logrotate config to the server.
This commit is contained in:
parent
b0e5245e4e
commit
82d5bd7d16
5 changed files with 90 additions and 32 deletions
22
tasks/create-logrotate-application-configuration-files.yml
Normal file
22
tasks/create-logrotate-application-configuration-files.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
- name: 'check if there exist log files for {{ item.name }}'
|
||||
shell:
|
||||
cmd: "ls -l {{ item.logs|join(' ') }}"
|
||||
changed_when: false
|
||||
register: _available_logs
|
||||
check_mode: false
|
||||
failed_when: false
|
||||
tags:
|
||||
- configuration
|
||||
|
||||
- name: 'create logrotate configuration file for {{ item.name }}'
|
||||
become: true
|
||||
template:
|
||||
src: 'etc/logrotate.d/application.j2'
|
||||
dest: '/etc/logrotate.d/{{ item.name }}'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
when: _available_logs.stdout_lines|length() > 0
|
||||
tags:
|
||||
- configuration
|
|
@ -44,15 +44,10 @@
|
|||
- configuration
|
||||
|
||||
- name: 'create logrotate application configuration files'
|
||||
become: true
|
||||
template:
|
||||
src: 'etc/logrotate.d/application.j2'
|
||||
dest: '/etc/logrotate.d/{{ item.name }}'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
with_items:
|
||||
- '{{ logrotate_applications }}'
|
||||
include_tasks: create-logrotate-application-configuration-files.yml
|
||||
loop: '{{ logrotate_applications }}'
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
tags:
|
||||
- configuration
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue