I'm having a problem wrapping my head around something.  There are other 
solutions out there that would solve my problem, but in the interest in 
learning to do something different I'm hoping someone can point out what 
I'm doing wrong with the lineinfile module.

I grep a file for a line with a specific line.  The file line is "auth        
required      pam_faillock.so preauth silent deny=3 unlock_time=604800 
fail_interval=900" and I want to verify that it's there exactly.  If it is 
there but not exact, I want to change it.  If it's missing I want to add it 
it a specific spot.  The only way I've been able to make it works is search 
and delete any line with the word "pam_faillock.so" in it and then run the 
module to add the line where it should be.  What I have below works, but 
every time I run it, it changes the file even if the line is correct of 
obvious reasons.  Any suggestions?  Am I using the wrong module to complete 
this task?  Thanks for the help.

- name: system-auth-ac - Delete current pam_faillock lines
  tags: [ 'pam' , 'system-auth-ac' , 'common' ]
  lineinfile: "dest=/etc/pam.d/system-auth-ac regexp='pam_faillock.so' 
state=absent"


- name: Configure system-auth-ac
  tags: [ 'pam' , 'system-auth-ac' , 'common' ]
  lineinfile: "dest=/etc/pam.d/system-auth-ac insertbefore='^auth        
sufficient    pam_unix.so' regexp={{ item.r }} line={{ item.l }}"
  with_items:
    - { r: '^auth required pam_faillock.so', l: "{{ pam_faillock_pre }}" }

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e4ab2680-c2ec-4345-b741-1520a4c3bb11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to