Write template from a string input

16 views
Skip to first unread message

Michael Stucki

unread,
Feb 10, 2015, 6:21:50 AM2/10/15
to ansible...@googlegroups.com
Hi!

I'm trying to write a file. As it's only one line, I would like to set it from a string input, not from a template file. Just something like:

- template: >
    dest=/etc/default/locale
    content='LC_ALL="en_US.UTF-8"'

As far as I can see, there is no such thing right now.

I'm working around that using the lineinfile module, but this is really cumbersome for such a purpose:

- lineinfile: >
    dest=/etc/default/locale
    line='LC_ALL="de_C2.UTF-8"'
    regexp='^'

I also think that the lineinfile module is not meant for this, but I also didn't find any other way. Does anyone know?

Greetings, Michael

Brian Coca

unread,
Feb 10, 2015, 7:24:05 AM2/10/15
to ansible...@googlegroups.com
I think you want the following:

- copy: >
dest=/etc/default/locale
content='LC_ALL="en_US.UTF-8"'



--
Brian Coca

Tom Bamford

unread,
Feb 10, 2015, 7:27:28 AM2/10/15
to ansible...@googlegroups.com
Hi Michael

The copy module does have a content parameter that should do what you want.

Regards
Tom


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7d1e28ed-990f-4d9c-a5c8-0d65c3e5b931%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Michael Stucki

unread,
Feb 10, 2015, 8:27:33 AM2/10/15
to ansible...@googlegroups.com
Many thanks, this works!

Michael
Reply all
Reply to author
Forward
0 new messages