Mona, I don't think you need the regexp parameter, just set 'insertafter: 
EOF' to get it to append at the end of the file. See for what works for me 
in one of my scripts:

- name: add script exec to bashrc
  lineinfile:
    dest: /home/.bashrc
    state: present
    line: '. /home/.profile-custom'
    insertafter: EOF


On Tuesday, June 14, 2016 at 2:12:29 AM UTC-4, Mona Gopal wrote:
>
> Hi All,
>
>  I figured out that the below works to append to a file,
>
> - name: Write redis details to file
>   local_action: lineinfile dest={{ third_party_dest_path }} line=redis 
> state=present create=yes
>
> However, i am unable to append the registered variable value to the file
>
> - name: Write redis details to file
>   local_action: lineinfile dest={{ third_party_dest_path }} *line="{{ 
> redis }}"* state=present create=yes
>
>
>
>
> On Tuesday, June 14, 2016 at 10:36:33 AM UTC+5:30, Mona Gopal wrote:
>>
>> Hi all,
>>
>> I am trying to use the lineinfile module to append  some of the software 
>> details to a file. 
>> I don't want to match to any regexp, but just insert every software 
>> details at the EOF.
>>
>>
>> Below is the piece of code.
>>
>> - name: Collect python details
>>   action: get_python_details 
>>   register: python
>>
>> - name: Write registered variable to file
>>   local_action: lineinfile dest={{ third_party_dest_path }}  line={{ 
>> python }} regexp="" insertafter=EOF state=present create=yes
>>
>> Have also tried giving regexp="^$", regexp="^\s*$" as well to match to 
>> an empty line, but throws the below error.
>>
>> Error:
>>
>> An exception occurred during task execution. The full traceback is:
>> Traceback (most recent call last):
>>   File 
>> "/root/.ansible/tmp/ansible-tmp-1465888759.41-82910653497853/lineinfile", 
>> line 2540, in <module>
>>     main()
>>   File 
>> "/root/.ansible/tmp/ansible-tmp-1465888759.41-82910653497853/lineinfile", 
>> line 371, in main
>>     ins_aft, ins_bef, create, backup, backrefs)
>>   File 
>> "/root/.ansible/tmp/ansible-tmp-1465888759.41-82910653497853/lineinfile", 
>> line 266, in present
>>     lines.append(line + os.linesep)
>> TypeError: unsupported operand type(s) for +: 'dict' and 'str'
>>
>> fatal: [172.19.3.60 -> localhost]: FAILED! => {"changed": false, "failed": 
>> true, "invocation": {"module_name": "lineinfile"}, "parsed": false}
>>
>>
>> Kindly help on how to go about appending to EOF without matching to any 
>> regexp.
>>
>>
>> Thanks in advance,
>>
>> Mona G
>>
>>

-- 
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/dca545a3-7137-4e64-84f3-4aa298240166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to