Write template from a string input

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

I think you want the following:

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

Hi Michael

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

Regards
Tom

Many thanks, this works!

Michael