"I want to rsync files from the host machine (ansible "master") to some other
machine but also overwrite some of the files on target machine that require
sudo to access."
This implies two things:
1) you should not use local_action, because synchronize's action plugin
automatically does this "delegation" action and will not use remote paths if
local_action is used.
2) you will need to set the rsync_path option to enable sudo on the remote host
rsync_path="sudo rsync"
Setting the rsync_path that way will imply two more things:
A) the user can sudo without a password
B) sudo does not require a tty
You are effectively doing all of this with your "local_action: shell" example,
but you aren't going to be able to get around the tty issue because that's
enforced by default in sudo. You'll have to turn it off.
On Apr 15, 2014, at 6:21 PM, Sibin Arsenijevic <[email protected]>
wrote:
> @James Tanner of course!
>
> This is site.yml which calls role streamer which in turn includes rsync.yml.
> I have made comments in pastebin which should put you right on the track.
>
> http://pastebin.com/7NAWgwnp
>
> @Michael DeHaan i have considered that (but didn't try it tbh) because i read
> that copy module doesn't handle large number of arguments (files) very well.
> Those static files that need to be copied number hundreds if not a thousand.
>
> Thank you both for taking the interest in my problem :)
>
> On Tuesday, April 15, 2014 5:24:16 PM UTC+2, James Tanner wrote:
> Formatting is a bit wonky in the email. Could you put the playbook/tasks on
> gist or paste bin?
>
> On Apr 15, 2014, at 8:53 AM, Sibin Arsenijevic <[email protected]>
> wrote:
>
>> First of all i want to tell you how amazed i am with Ansible! The more i
>> learn it the more amazed i am, it is a great peace of software.
>> But now, as always, i have a problem :)
>>
>> I've been having problems with rsync and ansible for a few days now, so i
>> guess i am missing something obvious :)
>>
>> I want to rsync files from the host machine (ansible "master") to some other
>> machine but also overwrite some of the files on target machine that require
>> sudo to access. Lets call my user test, this user exists on both "master"
>> and target machine and is part of sudo group on both machines.
>>
>> My play includes:
>>
>> remote_user: nettv
>> sudo: True
>> .
>> .
>> .
>> - name: RSYNC all the needed files for streamer
>> #synchronize: src=/home/test/streamer-image/opt/ dest=/opt/
>> rsync_timeout=5 rsync_path="sudo rsync"
>> #command: sudo rsync -avP -e "ssh -o StrictHostChecking=no" --partial
>> [email protected] /streamer-image/opt/ /opt/
>> local_action: shell rsync -avP "ssh -p {{ansible_ssh_port}}" --partial
>> --rsync-path="sudo rsync" /home/test/streamer-image/opt/
>> test@{{inventory_hostname}}:/opt/
>> when: roles_var == "str"
>>
>> When i try to use synchronize without sudo rsync i get permission denied
>> which i think is normal.
>> When i try to use synchronize with sudo rsync i get that tty is not present.
>> I have read about !requiretty but i would like to avoid this approach.
>> When i try to use command with sudo it just hangs (i guess it is waiting for
>> sudo password but without a prompt)
>> When i try to use local_action with sudo i get that tty is not present.
>>
>> In ansible.cfg I have this:
>>
>> sudo_user = root #But i have tried with test also, but if i change
>> to test my tasks won't run because of premissions (this puzzles me)
>>
>> executable = /bin/sh #But i have tired with /bin/bash also.
>>
>>
>> Files that are needed for example grub i will copy separately and describe
>> handlers and such, but the rest of the files i need to copy "in bulk" and
>> overwrite some of the files in /opt/, /etc/ and such.
>>
>> So, what am i doing wrong? Am i missing something obvious? Is there some
>> workaround?
>>
>> If you need any verbose output for any of the cases i will be happy to
>> provide them :)
>>
>> Any idea is highly appreciated! Thank you in advance!
>>
>>
>> --
>> 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/8076f133-5502-4905-8e65-db0b717e76f3%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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/cb40f0e8-c1f1-48aa-976f-3360731f50e6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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/FC7BC0EB-EDBD-49E5-B4F4-BF4B1746D754%40gmail.com.
For more options, visit https://groups.google.com/d/optout.