duplicate resource or dependency cycle when attempting to set default options
Closed this issue · 1 comments
GeoffWilliams commented
Affected Puppet, Ruby, OS and module versions/distributions
- Puppet: rspec-puppet
- Ruby: 2.5.1
- Distribution: RHEL7 selected
- Module version:
How to reproduce (e.g Puppet code you use)
Duplicate resource logrotate::conf
class { '::logrotate':}
logrotate::conf { '/etc/logrotate.conf':
* => $default_settings,
}
Dependency cycle
logrotate::conf { '/etc/logrotate.conf':
* => $default_settings,
}
-> class { '::logrotate':}
What are you seeing
The above code looks to be possible after looking at README.md. I haven't yet tried the code with puppet as both versions fail with rspec-puppet errors:
Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Logrotate::Conf[/etc/logrotate.conf] is already declared at (file: /home/geoff/github/r_profile/spec/fixtures/modules/logrotate/manifests/defaults.pp, line: 12); cannot redeclare (file: /home/geoff/github/r_profile/spec/fixtures/modules/r_profile/manifests/linux/logrotate.pp, line: 46) (file: /home/geoff/github/r_profile/spec/fixtures/modules/r_profile/manifests/linux/logrotate.pp, line: 46, column: 3) on node computer
and
Failure/Error: it { should compile }
dependency cycles found: (File[/etc/logrotate.conf] => Logrotate::Conf[/etc/logrotate.conf] => Class[Logrotate] => Class[Logrotate::Install] => Package[logrotate] => File[/etc/logrotate.conf])
respectively
What behaviour did you expect instead
Expect to be able to include the main class and set the Logrotate::Conf[/etc/logrotate.conf]
Output log
n/a
Any additional information you'd like to impart
The errors look to be caused by use of if ! defined()
in /manifests/defaults.pp
. Am currently looking at putting together a PR to remove this and instead use optionally defined hash of default settings on main class.
GeoffWilliams commented
Ok looks like I just read the docs wrong:
class { '::logrotate':
ensure => 'latest',
config => {
dateext => true,
compress => true,
rotate => 10,
rotate_every => 'week',
ifempty => true,
}
}
works, as does
logrotate::conf { '/etc/logrotate.conf':
rotate => 10,
rotate_every => 'week',
ifempty => true,
dateext => true,
}
on its own
- Will see about a docs enhancement instead