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 [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/979288ed-eb60-4d20-8f6c-9dd415ce7ef4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.