D
D
Dmitry Erokhin2017-01-18 18:23:41
Ansible
Dmitry Erokhin, 2017-01-18 18:23:41

How to replace a word in ansible module lineinfile instead of the whole line?

I want to replace true with false using ansible in the config file.
Through the shell module using sed there are no problems, but through lineinfile I can only edit by replacing the entire line, I want only one word to be replaced, how to do it?
shell:

- name: edit
        shell: sed -i "/login-users/ s|true|false|" /opt/templ.xml

line file:
- name: edit
        lineinfile:
          dest: /opt/templ.xml
          regexp: login-users
          line: <loginusers>false</login-users>
          backrefs: yes
          state: present

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2017-01-19
@erohin_d

as far as I remember, this cannot be done through lineinfile

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question