Ansible template; change only one line in existing file using jinja2 template without more changes in file

Viewed 34

How to change in ansible one line in existing file using template knowing only one line that need to be changed like below.

bar: xxx

The simplest way is to use ansible module lineinfile, but it is not the case. How to do it with template using jinj2 formatting without knowing existing lines contents and prevent their modification.

app.txt - existing file

foo: aaa
bar: bbb
lorem: ccc

app.txt - expected output

foo: aaa
bar: xxx
lorem: ccc
0 Answers
Related