Sync folder from remote permissions denied

Hi,

I´d like to sync logfiles from a remote ubuntu 12.04 server to my local computer:

That´s what my Playbook looks like:

`

  • hosts: “{{targets}}”
    vars:
    remote_user: “{{username}}”
    tasks:

  • name: Synchronize log files
    synchronize: src=/var/log/apache2/ dest=/Users/me/Desktop/logs/ mode=pull
    sudo: yes

`

unfortuntely it fails with:

`
msg: sudo: no tty present and no askpass program specified
Sorry, try again.

`

If I run the playbook without sudo:yes I get a permission denied as the specified user is not member
of root or adm group.

(That´s what the Remote Folder looks like )

`
drwxr-x— 3 root adm 12288 Mar 15 06:25 apache2

`

I think a workaround could be to add the user to root or adm group or change chmod of the remote folder,
but this is a kind of ugly. Is there a way to grant rights (sudo -i) to the user via ansible?

best,

anatol

As I disabled root access from ssh, I´ve ended up adding the user to adm group

`
sudo usermod -aG adm

`

and exluded a file which belongs to root

`
synchronize: src=/var/log/apache2/ dest=/Users/me/Desktop/logs/ mode=pull rsync_opts=–exclude=.elinks

`