Kai Stian Olstad [29.06.2016 15:21]: > On 29. juni 2016 08:07, Werner Flamme wrote: >> The module instead scans the file, and on the first run it behaves as I >> expect, the line in the file is modified. On subsequent runs, one line >> (per run) is added to the file (before EOF), so that I have multiple >> lines containing "line". >> >> Is this behaviour expected? How can I make a replacement only when >> "regex" matches? > > No, and you are not alone > https://github.com/ansible/ansible-modules-core/issues/3975 >
Yes, that's exactly what happens here. Thank you for pointing me there.
I already thought of using an "absent" and a "present" task, but now I
use the replace module, and it seems to work:
- name: replace kernel multiversions
replace:
dest: /etc/zypp/zypp.conf
regexp: "^multiversion.kernels = latest,latest-1,running"
replace: "multiversion.kernels = latest,oldest,running"
BTW, I'm running ansible version 2.1.0.0, and it's the first time I use
the lineinfile module (since I'm quite new to ansible).
Regards,
Werner
--
--
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/87ead8b4-752a-9199-06b6-adc338227383%40ufz.de.
For more options, visit https://groups.google.com/d/optout.
smime.p7s
Description: S/MIME Cryptographic Signature
