"Besides the above, another issue is whether it is good default behavior to connect to localhost through ssh if 'ansible_connection' is undefined"
It depends if localhost is in inventory or not, but there is nothing to presume an explicit entry of localhost has requested a particular way to connect. On Tue, May 13, 2014 at 1:13 PM, 'Petros Moisiadis' via Ansible Project < [email protected]> wrote: > On 05/13/14 18:36, Michael DeHaan wrote: > > There's a degree of fuzzy logic in the synch module to understand > localness, but it's not perfect --- it was actually pretty surprising how > complex "guessing" the right params to sync needed to be. > > To understand this further though, can we please see the lines from your > playbook that you are using? This can make sure we're talking about the > same things. > > Thanks! > > > On Mon, May 12, 2014 at 3:22 PM, 'Petros Moisiadis' via Ansible Project < > [email protected]> wrote: > >> On 05/12/14 22:10, 'Petros Moisiadis' via Ansible Project wrote: >> > I am trying to use the synchronize module and I notice that it first >> > connects as root at the local machine before calling rsync. However, >> > root user's ssh key is not set in the authorized keys of the remote host >> > root user, so it prompts for password, which causes ansible-playbook to >> > hang. I don' t want to rsync from the local machine as root user. I want >> > to rsync as the current user when invoking ansible-playbook, which Ι >> > think should be the expected behavior. Am I missing something here? >> > >> > Ansible version: 1.6.1 >> > >> >> Well, I worked around it by setting ansible_connection to 'local' for >> localhost. However, I think it should also work with 'ssh' by connecting >> as the current user (not as 'root'). >> >> -- >> 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/53711F71.9040005%40yahoo.gr >> . >> 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/CA%2BnsWgzxYTXONZYc7iOcjV7Lup2OiFmHLSYgGsspxKdoumcBkg%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzxYTXONZYc7iOcjV7Lup2OiFmHLSYgGsspxKdoumcBkg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > > > The playbook looks like this: > > - hosts: "{{ target }}" > user: root > roles: > - somerole > > and the synchronize task in somerole looks like this: > > - name: Synchronize some dir > synchronize: src=relative/path/to/some/dir dest=/full/path/to/some/dir > delete=yes recursive=yes > > {{ target }} is always a remote machine. > > If 'ansible_connection' is NOT set to 'local' for the localhost (actually, > if it is not set at all), the synchronize module connects to the local > machine through ssh as 'root'. Is this because of the "user: root" in the > playbook? If this is the case, it is wrong because "user: root" is actually > a synonym for "remote_user: root" and synchronize should not pick the > "remote_user" when connecting on the "local" machine. > > Besides the above, another issue is whether it is good default behavior to > connect to localhost through ssh if 'ansible_connection' is undefined. > Maybe ansible should use the 'local' connection when connecting to > localhost unless any of the 'ansible_connection' configuration option or > the 'connection' playbook parameter is set to a different value. > > -- > 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/537252C2.9000707%40yahoo.gr<https://groups.google.com/d/msgid/ansible-project/537252C2.9000707%40yahoo.gr?utm_medium=email&utm_source=footer> > . > > 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/CA%2BnsWgy0xtVAk3LQpnEXTUVqy%2By3bNTm4oS7Y38gnLvKZSJPmw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
