I like it. Thanks
Il giorno martedì 13 febbraio 2018 16:50:44 UTC, Matt Martz ha scritto:
>
> I would honestly use slurp to fetch the file and maybe a set_fact to set a
> var indicating it's existence. That is the pattern I have always used.
> Something like:
>
> - slurp:
> path: /etc/myfile
> register: myfile
>
> - set_fact:
> contains_cmdline: "{{ myfile.contents|b64decode|search("^CMDLINE") }}"
>
> On Tue, Feb 13, 2018 at 10:45 AM, Nico Sabbi <[email protected]
> <javascript:>> wrote:
>
>> HI,
>> I need to do a grep-like search in a file without using shell commands
>> and in a check_mode compatible way.
>> I just need to check the presence of a given string a in a file without
>> doing overwrites of any kind.
>> I implemented something with lineinfile but I'm very annoyed by the need
>> to specify the line parameter to overwrite the file
>> because the r.e. may be wrong.
>>
>> Is there any cleaner way to do what I need?
>>
>> - name: grub
>> become: true
>> lineinfile:
>> path: /etc/myfile
>> backrefs: yes
>> regexp: "^CMDLINE (.*)"
>> line: 'CMDLINE \1'
>> state: present
>> register: myxx
>>
>>
>> Thanks.
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/0ca75bd8-67b9-43f3-87cb-0dbdeacd0088%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/0ca75bd8-67b9-43f3-87cb-0dbdeacd0088%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Matt Martz
> @sivel
> sivel.net
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a70b50d5-fa9b-48cb-9903-b9e58722aba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.