On Saturday, 14 April 2018 10.01.38 CEST Agoston Bejo wrote:
> Version a)
>
> - name: create the file as root
> shell: 'echo "Test_string" > /root/test.txt'
> remote_user: root
>
> - name: replace '_' with '-' in the file
> replace:
> path: "/root/test.txt"
> regexp: '_'
> replace: '-'
> backup: no
>
> ==> it fails, because the replace task doesn't accept either remote_user or
> sudo_user as a parameter, so it can only be run as the user running the
> playbook, and that user can't modify a file created by root
remote_user and become_user(sudo_user is depricated) is a directive for the task, not the module so you indentation is probably wrong.
They must be on the same level as replace.
--
Kai Stian Olstad