Issue with Variable Evaluation
bdwyertech opened this issue · 2 comments
bdwyertech commented
For one reason or another, logrotate_app seems to have a problem evaluating Resource Properties.
If I try passing in service_user
as create "644 #{service_user} #{service_user}"
Recipe: <Dynamically Defined Resource>
* template[/etc/logrotate.d/MyApp] action create
- update content in file /etc/logrotate.d/MyApp from f37b2e to 2ac241
--- /etc/logrotate.d/MyApp 2016-01-22 17:44:23.244140684 -0700
+++ /etc/logrotate.d/.MyApp20160122-28294-36d27x 2016-01-22 17:46:41.888167833 -0700
@@ -3,7 +3,7 @@
"/var/log/MyApp/error.log" {
daily
- create 644 root root
+ create 644 [] []
rotate 30
missingok
delaycompress
* template[PHP Configuration (MyApp)] action create (up to date)
This doesn't work
Defined as property :service_name, String, name_property: true
logrotate_app service_name do
cookbook 'logrotate'
path [::File.join(log_dir, 'error.log')]
frequency 'daily'
options ['missingok', 'delaycompress', 'notifempty']
postrotate "invoke-rc.d #{service_name} reopen-logs > /dev/null"
sharedscripts true
rotate 30
create '644 root root'
end
This Works
lr_service_name = service_name
logrotate_app service_name do
cookbook 'logrotate'
path [::File.join(log_dir, 'error.log')]
frequency 'daily'
options ['missingok', 'delaycompress', 'notifempty']
postrotate "invoke-rc.d #{lr_service_name} reopen-logs > /dev/null"
sharedscripts true
rotate 30
create '644 root root'
end
Finally, if you try to use a lazy evaluator, it passes the lazy evaluator object as a string.
github-actions commented
Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.
bdwyertech commented
I will test this again in the next week or so and see if the issue still exists. Maybe it was a Ruby version issue or something.