Write multiple lines to a file using local_action

955 views
Skip to first unread message

jamesv...@gmail.com

unread,
Jun 22, 2016, 2:32:53 PM6/22/16
to Ansible Project
I am using the command:
- local_action: copy content="The installation failed" dest=~/ansible/ansible_log.txt

However, when I do it again:
- local_action: copy content="Contact me for assistance" dest=~/ansible/ansible_log.txt

It overwrites the new text with the old text. What I want to do is append to the file instead of replacing the previous text.

I tried adding in a /n to the end of the original string to no avail.

Kai Stian Olstad

unread,
Jun 22, 2016, 3:08:58 PM6/22/16
to ansible...@googlegroups.com
On 22. juni 2016 20:32, jamesv...@gmail.com wrote:
> I am using the command:
> - local_action: copy content="The installation failed"
> dest=~/ansible/ansible_log.txt
>
> However, when I do it again:
> - local_action: copy content="Contact me for assistance"
> dest=~/ansible/ansible_log.txt
>
> It overwrites the new text with the old text. What I want to do is append
> to the file instead of replacing the previous text.

copy can't do that, check out lineinfile
https://docs.ansible.com/ansible/lineinfile_module.html

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages