Hi All, I have file below, would like to comment out the line with hmac-sha1 and uncomment like with #Commened for LINUXMSB 2013'
$ cat sshd_config MACs [email protected],[email protected],hmac-sha2-512,hmac-sha2-256 #Added below for LINUXMSB 2013 MACs hmac-sha2-512,hmac-sha2-256,hmac-sha1 Interestingly if dont use loop(with_items), it works fine. When i use with with_item, it adds another escape character, Am i missing something? Here is the code: $ cat sshd.yml --- - hosts: localhost connection: local tasks: #- replace: # path: sshd_config # regexp: '(.*hmac-sha1.*)' # replace: '#\1' #- replace: # path: sshd_config # regexp: '#Commented for LINUXMSB 2013 ' - replace: path: sshd_config regexp: "{{item.exp}}" replace: "{{item.rep}}" with_items: - { exp: '(.hmac-sha1.)', rep: '# \1' } - { exp: '#Commented for LINUXMSB 2013 ', rep: '' } Here is ansible run: $ ansible-playbook sshd.yml [WARNING]: Could not match supplied host pattern, ignoring: all [WARNING]: provided hosts list is empty, only localhost is available PLAY [localhost] **************************************************************************************************************************************************** TASK [Gathering Facts] ********************************************************************************************************************************************** ok: [localhost] TASK [replace] ****************************************************************************************************************************************************** ok: [localhost] => (item={u'rep': u'# \\1' <file://1'/>, u'exp': u'(.hmac-sha1.)'}) ok: [localhost] => (item={u'rep': u'', u'exp': u'#Commented for LINUXMSB 2013 '}) PLAY RECAP ********************************************************************************************************************************************************** localhost : ok=2 changed=0 unreachable=0 failed=0 -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/d635f1be-1807-4d92-aca9-2ccf507e0993%40googlegroups.com.
