/xx/xx/xx.log {
weekly
copytruncate
rotate 8
compress
maxage 180
missingok
}
2. Create the symlink for above create file xxx_logrotate.conf to /etc/logrotate.d/xxx_logrotate.conf
My approach
1. I went ahead creating the file with using erb tempalte for adding the file content but when I create a new resource to create the symlik for the source and target. The puppet run fails with duplicate file resource
file { 'xxx-log-rotation-config-file':
ensure => 'present',
path => '/xxx/conf/xxx_logrotate.conf',
content => template('aaa/xxx_logrotate.conf.erb'),
owner => 'root',
group => 'root',
}
file { '/xxx/conf/xxx_logrotate.conf':
ensure => 'link',
target => '/etc/logrotate.d/xxx_logrotate.conf',
require => File['xxx-log-rotation-config-file'],
}
The puppet run fails for above code with below error
Error: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: File[/xxx/conf/mysql_logrotate.conf] is already declared in file /etc/puppetlabs/code/environments/production/modules/xxx/manifests/postinstall.pp:46; cannot redeclare at /etc/puppetlabs/code/environments/production/modules/xxx/manifests/postinstall.pp:54 at /etc/puppetlabs/code/environments/production/modules/xxx/manifests/postinstall.pp:54:3
Is there a better way of handling this without any issue using file resource?