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