On Mon, 8 Mar 2021 06:33:03 -0800 (PST)
"[email protected]" <[email protected]> wrote:

 - name: update file
   lineinfile:
     path: {{ my_path }}
     regexp: "{{ item.from }}"
     line: "{{ item.replace_with }}"
   with_items:
      - {from: parameter1= , replace_with: parameter1=test1}
      - {from: parameter1= , replace_with: parameter1=test2}

This will replace the "last line found". Twice. Quoting from "regexp"
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html#parameter-regexp

  "The regular expression to look for in every line of the file ...
  Only the last line found will be replaced."

You might want to mark the blocks and use *blockinfile* if you can't
use *template*.

-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20210308161153.38a0894f%40gmail.com.

Attachment: pgplMpyKtpPp5.pgp
Description: OpenPGP digital signature

Reply via email to