Instead of forcing the replacement, does it make sense to update 
template_from_file to properly read \r\n vs \n? I think it'd be better to 
keep the file as-is regardless of the line endings instead of having to 
turn replacement on/off via parameter. Or is template_from_file something 
from jinja2 that we can't really modify? I haven't looked too far into that 
yet.

On Saturday, December 27, 2014 3:49:36 PM UTC-8, J Hawkesworth wrote:
>
> Ok, as it stands, it seems the templating only generates \n line endings.
>
> Its easy enough to force dos line endings by making a one-line change to 
> win_template.py 
> after
>      resultant = template.template_from_file(self.runner.basedir, source, 
> inject, vault_password=self.runner.vault_pass)
> just add
>      resultant = resultant.replace('\n', '\r\n')
>
> However, I'm wondering whether it should be optional.
>
> Since you have a use case, do you have an opinion on whether something 
> like 'force_dos_line_endings' should be a module parameter for 
> win_template.  If so I'm guessing defaulting it to True would be the best 
> option?
>
> Jon
>
>
> On Wednesday, December 24, 2014 8:52:22 AM UTC, J Hawkesworth wrote:
>>
>> I think that should be enough too.  Soon as I get the chance I'll see if 
>> I can work out what is going on.
>>
>> Jon
>>
>> On Monday, December 22, 2014 6:50:57 PM UTC, Joey wrote:
>>>
>>> Checked with od and I have \r\n at the end of every line, which I think 
>>> should do it.
>>>
>>> On Saturday, December 20, 2014 9:19:25 AM UTC-8, J Hawkesworth wrote:
>>>>
>>>> Hmm... not sure the integration tests cover this, could be a bug.
>>>>
>>>> I'd try using 
>>>>
>>>> od -cx your_template | more
>>>>
>>>>  to make sure you have got CR and LF at the end of your lines to start 
>>>> with.  If they are there in the template then please shout, as it sounds 
>>>> like it might need a fix.
>>>>
>>>> Jon
>>>>
>>>>
>>>>
>>>> On Thursday, December 18, 2014 5:48:02 PM UTC, Joey wrote:
>>>>>
>>>>> I'm using win_template to copy a text file with a couple variables to 
>>>>> a windows client. However, it seems to be removing all lines breaks from 
>>>>> the file. I tried using unix2dos on the template, as well as adding 
>>>>> "#jinja2:trim_blocks: 
>>>>> False", but neither one seemed to work. Any other ideas?
>>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f920615f-b7fd-455a-82aa-9b3dcbd33dbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to