On Thu, 20 Feb 2020 09:25:26 -0800 (PST)
João Santos <morgado.san...@gmail.com> wrote:

>    - I have a file and want to insert in the beginning of each line the # 
>      character
>    - No matter if it has 10 lines or 1000 lines
>    - The final goal would be to no matter which file I said so, will add # 
>      to the beginning of line

Use "replace" module. For example
https://docs.ansible.com/ansible/latest/modules/replace_module.html#replace-replace-all-instances-of-a-particular-string-in-a-file-using-a-back-referenced-regular-expression

    - replace:
        path: "{{ item }}"
        regexp: '^(.*)$'
        replace: '# \1'
      loop: "{{ list_of_files }}"

HTH,

        -vlado

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200220195319.339d361d%40gmail.com.

Attachment: pgpSZpK6xJJKT.pgp
Description: OpenPGP digital signature

Reply via email to