I am using ansible logrotate definition for logrotate in ubuntu 14.04 which is having definition as below
---
- name: dependencies
apt: pkg={{item}} state=latest
with_items:
- unzip
- jq
- name: check if already downloaded
stat: path={{nomad_download_folder}}/{{nomad_archive}}
register: nomad_archive_stat
- name: download
get_url: >
url={{nomad_download}}
dest={{nomad_download_folder}}
sha256sum={{nomad_checksum}}
register: nomad_downloaded
when: nomad_archive_stat.stat.exists == false
- name: group
group: >
name={{nomad_group}}
state=present
register: nomad_group_created
# On Nomad schedulers
- name: user
user: >
home={{nomad_home}}
name={{nomad_user}}
system=yes
groups={{nomad_group}}
append=yes
when: (nomad_group_created | changed) and (nomad_is_server == true)
# On Nomad runners
- name: user
user: >
home={{nomad_home}}
name={{nomad_user}}
system=yes
groups={{nomad_group}},docker
append=yes
when: (nomad_group_created | changed) and (nomad_is_server == false)
- name: directories
file: >
state=directory
path={{item}}
owner={{nomad_user}}
group={{nomad_group}}
with_items:
- "{{nomad_home}}"
- "{{nomad_home}}/bin"
- "{{nomad_config_dir}}"
- name: check for log directory
stat: path={{nomad_log_file | dirname}}
register: nomad_log_directory_stat
- name: create log directory
file: >
state=directory
path={{nomad_log_file | dirname}}
owner={{nomad_user}}
group={{nomad_group}}
when: not nomad_log_directory_stat.stat.exists
- name: touch log file
file: >
state=touch
path={{nomad_log_file}}
owner={{nomad_user}}
group={{nomad_group}}
changed_when: false
- name: install
unarchive: >
src={{nomad_download_folder}}/{{nomad_archive}}
dest={{nomad_home}}/bin
copy=no
when: nomad_downloaded | changed
- name: link executable in PATH
file: >
state=link
src={{nomad_home}}/bin/nomad
dest=/usr/local/bin/nomad
- name: set ownership
file: >
state=directory
path={{nomad_home}}
owner={{nomad_user}}
group={{nomad_group}}
recurse=yes
when: nomad_downloaded | changed
- name: nomad config file
template: >
src=nomad.conf.j2
dest={{nomad_config_file}}
owner={{nomad_user}}
group={{nomad_group}}
mode=0755
notify:
- restart nomad
- name: copy nomad upstart script
template: >
src=nomad.upstart.conf.j2
dest=/etc/init/nomad.conf
owner={{nomad_user}}
group={{nomad_group}}
mode=0755
notify:
- restart nomad
- name: rotate log file
logrotate: name=nomad path={{nomad_log_file}}
args:
options:
- daily
- missingok
- rotate 3
- compress
- delaycompress
- copytruncate
- notifempty
Which causes to generate file with weird syntax which is below.
sudo cat /etc/logrotate.d/nomad
# Generated by Ansible.
# Local modifications will be overwritten.
/var/log/nomad.log {
[
'
d
a
i
l
y
'
,
'
m
i
s
s
i
n
g
o
k
'
,
'
r
o
t
a
t
e
3
'
,
'
c
o
m
p
r
e
s
s
'
,
'
d
e
l
a
y
c
o
m
p
r
e
s
s
'
,
'
c
o
p
y
t
r
u
n
c
a
t
e
'
,
'
n
o
t
i
f
e
m
p
t
y
'
]
}
Due to this syntax error I am getting so many emails every morning. Below are more details about server.
$sudo ansible --version
ansible 2.2.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty