# comment allowed in a template file?
I've found that dropping files in to the templates directory is a simple and convenient way to make certain things happen. E.g. I can set a default footer for all posts by putting the desired content in a file called var/templates/site/en/list:member:generic:footer.txt.
I'm running Mailman 3 in maxking's Docker container. I'm also using Puppet to do as much configuration as possible, so I'd like to add a comment to the file that reads something like: # This file is managed by Puppet.
Is it ok to do this? I may not have searched the docs enough, but I couldn't find anything relating to comments.
One other observation in case it's any use: Initially, I created the template files with owner set to "root". This resulted in postings to lists getting stuck in mailman-core. It's vital that these files are owned by user "mailman". Once I changed the owner of the file to the latter, everything worked.
Stephen
On 7/24/20 3:19 AM, skenny@scss.tcd.ie wrote:
I'm running Mailman 3 in maxking's Docker container. I'm also using Puppet to do as much configuration as possible, so I'd like to add a comment to the file that reads something like: # This file is managed by Puppet.
Is it ok to do this? I may not have searched the docs enough, but I couldn't find anything relating to comments.
If you mean can you add a '#' line that won't be part of the actual rendered template, the answer is No.
One other observation in case it's any use: Initially, I created the template files with owner set to "root". This resulted in postings to lists getting stuck in mailman-core. It's vital that these files are owned by user "mailman". Once I changed the owner of the file to the latter, everything worked.
I don't think they need to be owned by 'mailman' as long as they are readable by 'mailman'
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Mark Sapiro wrote:
If you mean can you add a '#' line that won't be part of the actual rendered template, the answer is No.
OK, thanks for the clarification.
Initially, I created the template files with owner set to "root". This resulted in postings to lists getting stuck in mailman-core. It's vital that these files are owned by user "mailman". Once I changed the owner of the file to the latter, everything worked. I don't think they need to be owned by 'mailman' as long as they are readable by 'mailman'
Yes, your formulation is a more accurate statement than mine (I could have instead simply relaxed the permissions on the files to make them world-readable).
The effect of the template files not being readable by user "mailman" was interesting. Hundreds of lines like the following got written to mailman-core's var/log/smtp.log file at the rate of 4 per second:
Jul 23 17:09:54 2020 (25) Using agent: <mailman.mta.bulk.BulkDelivery object at 0x7fdf9e7b5f28>
(the hex number was different each time).
Having excessively restrictive permissions on the template files is a silly - but easy enough - mistake to make. If it were possible to add it to Mailman 3, a more descriptive logging message could point others who make it in the right direction, perhaps. I spent a long time trying to figure out why messages weren't getting sent out from Mailman core, and in the end it was luck in form of a colleague's suggestion about file permissions that got me out of the rut.
Thanks for the great support,
Stephen Kenny
On 7/27/20 5:15 AM, skenny@scss.tcd.ie wrote:
The effect of the template files not being readable by user "mailman" was interesting. Hundreds of lines like the following got written to mailman-core's var/log/smtp.log file at the rate of 4 per second:
Jul 23 17:09:54 2020 (25) Using agent: <mailman.mta.bulk.BulkDelivery object at 0x7fdf9e7b5f28>
(the hex number was different each time).
That's a debug
level log message written for every delivery. It has
nothing to do with the unreadable templates except that the unreadable
template causes looping in an attempt to send the message.
Did you perhaps set
[logging.smtp] level: debug
in an effort to diagnose the template issue?
Having excessively restrictive permissions on the template files is a silly - but easy enough - mistake to make. If it were possible to add it to Mailman 3, a more descriptive logging message could point others who make it in the right direction, perhaps. I spent a long time trying to figure out why messages weren't getting sent out from Mailman core, and in the end it was luck in form of a colleague's suggestion about file permissions that got me out of the rut.
There is clearly a bug in that an unreadable template should just be skipped and the fact logged. I have reported <https://gitlab.com/mailman/mailman/-/issues/745>.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
skenny@scss.tcd.ie writes:
I've found that dropping files in to the templates directory is a simple and convenient way to make certain things happen. E.g. I can set a default footer for all posts by putting the desired content in a file called var/templates/site/en/list:member:generic:footer.txt.
I'm running Mailman 3 in maxking's Docker container. I'm also using Puppet to do as much configuration as possible, so I'd like to add a comment to the file that reads something like: # This file is managed by Puppet.
This is a pure comment, right? I mean, Puppet doesn't pay any attention to it, that's just so you don't go editing that file.
As Mark says, there's no supported way to add comments to a template. But as a horrifying hack, assuming a pure comment, one could add the key 'This_file_is_managed_by_Puppet' with value "" to the dict used for template rendering. Then your file would look like
${This_file_is_managed_by_Puppet}\
This is the original text of the template string.
I'm not sure if the \-newline hack would actually work. You might need to accept an initial newline in the rendered text, or have a long first line like
${This_file_is_managed_by_Puppet}This is the original text of the template string.
It's probably too ugly for prime time, but thinking about hacks like this give me joy. ;-)
participants (3)
-
Mark Sapiro
-
skenny@scss.tcd.ie
-
Stephen J. Turnbull