John,

John Oliver schrieb (29.07.2014 19:38 Uhr):
Example:

password sufficient pam_unix.so shadow nullok try_first_pass use_authtok

And I want to wind up with:

password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok

And let's assume I don't know what might come after pam_unix.so, and want to preserve whatever's there, and so can't just use line="string of text"

Right now, I'd use 'command' or 'shell' to call sed or awk to accomplish this. But is there a way to massage ansible into doing this?
The second last example for lineinfile does use regex with a backreference:
http://docs.ansible.com/lineinfile_module.html
"- lineinfile: dest=/opt/jboss-as/bin/standalone.conf regexp='^(.*)Xms(\d+)m(.*)$' line='\1Xms${xms}m\3' backrefs=yes"

For a start something like:
regex='^password sufficient pam_unix.so (.*)' line='password sufficient pam_unix.so sha512 \1' backrefs=yes

You may have to take care \1 does not contain "sha512", so .* may not be safe enough.


Marc

--
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/53D90EB3.6080308%40ofd-z.niedersachsen.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to