Copy directory from the remote. ssh is set. I am able to access the remote without the password but still facing issue while copying. --- - name: sync pull task hosts: localhost connection: local become: true become_user: user tasks: - name: copying file using pull synchronize: src: /home/sss/mypath/ dest: /home/user/ansibleworkspace/ mode: pull rsync_path: "sudo_rsync" recursive: true delegate_to: '{{ item }}' with_inventory_hostnames: targetservers
I m trying to copy a directory from remote, but it's not happening. Its getting paused. output: user@thu:~/ansibleworkspace$ ansible-playbook checkremote.yml PLAY [sync pull task] ********************************************************** TASK [Gathering Facts] ********************************************************* ok: [localhost] TASK [copying file using pull] ************************************************* How to resolve it????????? On Tuesday, July 10, 2018 at 10:47:15 PM UTC+5:30, Toshio Kuratomi wrote: > > Your hosts file appears to be using groups for ServerA and ServerB. > delegate_to doesn't actually know about groups so delegate_to is not > finding an ansible host with that name and then it's consulting dns as > a fallback. there are several ways to achieve what you want, though. > > * In your example hosts file, it looks like you can define a host > rather than a group for ServerA and ServerB. > * If you do have multple Servers to process, you can use a loop: > > - name: Transferring file from ServerA to ServerB > synchronize: > src: /home/ubuntu/Dockerfile > dest: /home/ubuntu > delegate_to: '{{ item }}' > with_inventory_hostnames: ServerA > > -Toshio > > On Tue, Jul 10, 2018, 8:30 AM Abhinav G <abhinav...@gmail.com > <javascript:>> wrote: > > > > Hi Shubham > > > > If you can observe the verbose output rather than connecting to > 192.168.1.2 it is trying to connect to 198.105.254.228 , 198.105.244.228. > These ip's are not mentioned in the host file nor the server ip address. > Why is it connecting to those addresses. > > > > On Tue, Jul 10, 2018 at 10:23 AM, Shubham Gampawar < > shubham....@gmail.com <javascript:>> wrote: > >> > >> Can you please try to run playbook with the increased timeout value. > >> > >> On Jul 10, 2018 8:45 PM, <abhinav...@gmail.com <javascript:>> wrote: > >>> > >>> I am trying to copy the files from Server A to Server B with Ansible > running in Server C. > >>> > >>> I have tried using Ansible Synchronize Module: > >>> > >>> Exchanged SSH id_rsa.pub keys between the servers. Was able to ssh > between the servers without asking password. > >>> > >>> When running playbook it was able to gather_facts but throwing error > during task execution. If seen in verbose output it is trying yo connect to > different ip's rather than the ips mentioned in the host file. > >>> > >>> Hosts file > >>> > >>> [ServerA] 192.168.1.7 ansible_user=ubuntu > >>> [ServerB] 192.168.1.2 ansible_user=ubuntu > >>> > >>> main.yml > >>> > >>> --- > >>> - hosts: ServerB > >>> become: yes > >>> tasks: > >>> - name: Transferring file from ServerA to ServerB > >>> synchronize: > >>> src: /home/ubuntu/Dockerfile > >>> dest: /home/ubuntu > >>> delegate_to: ServerA > >>> > >>> Output: > >>> > >>> ubuntu@ansible-VirtualBox:~/playbooks/migration$ ansible-playbook -i > hosts main.yml PLAY [ServerB] > *************************************************************************************************************************************************************************************************************************** > > > >>> TASK [Gathering Facts] > ******************************************************************************************************************************************************************************************************************* > > > >>> ok: [192.168.1.2] > >>> > >>> TASK [Trasferring file from ServerA to ServerB] > ******************************************************************************************************************************************************************************************* > > > >>> fatal: [192.168.1.2]: UNREACHABLE! => {"changed": false, "msg": > "Failed to connect to the host via ssh: ssh: connect to host servera port > 22: Connection timed out\r\n", "unreachable": true} to retry, use: > --limit @/home/ubuntu/playbooks/migration/main.retry > >>> > >>> PLAY RECAP > ******************************************************************************************************************************************************************************************************************************* > > > >>> 192.168.1.2 : ok=1 changed=0 unreachable=1 > failed=0 > >>> > >>> Verbose Output: > >>> ok: [192.168.1.2] META: ran handlers > >>> > >>> TASK [Traferring file from ServerA to ServerB] > ******************************************************************************************************************************************************************************************* > > > >>> task path: /home/ubuntu/playbooks/migration/main.yml:5 <ServerA> > ESTABLISH SSH CONNECTION FOR USER: None <ServerA> SSH: EXEC ssh -vvv -C -o > ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no > -o > PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey > -o PasswordAuthentication=no -o ConnectTimeout=10 -o > ControlPath=/home/ubuntu/.ansible/cp/b9f15bf7e0 ServerA '/bin/sh -c > '"'"'echo ~ && sleep 0'"'"'' <ServerA> (255, '', 'OpenSSH_7.2p2 > Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016\r\ndebug1: Reading > configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line > 19: Applying options for *\r\ndebug1: auto-mux: Trying existing > master\r\ndebug1: Control socket "/home/ubuntu/.ansible/cp/b9f15bf7e0" does > not exist\r\ndebug2: resolving "servera" port 22\r\ndebug2: > ssh_connect_direct: needpriv 0\r\ndebug1: Connecting to servera > [198.105.244.228] port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: > connect to address 198.105.244.228 port 22: Connection timed out\r\ndebug1: > Connecting to servera [198.105.254.228] port 22.\r\ndebug2: fd 3 setting > O_NONBLOCK\r\ndebug1: connect to address 198.105.254.228 port 22: > Connection timed out\r\nssh: connect to host servera port 22: Connection > timed out\r\n') fatal: [192.168.10.182]: UNREACHABLE! => { "changed": > false, "msg": "Failed to connect to the host via ssh: OpenSSH_7.2p2 > Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016\r\ndebug1: Reading > configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line > 19: Applying options for *\r\ndebug1: auto-mux: Trying existing > master\r\ndebug1: Control socket \"/home/ubuntu/.ansible/cp/b9f15bf7e0\" > does not exist\r\ndebug2: resolving \"servera\" port 22\r\ndebug2: > ssh_connect_direct: needpriv 0\r\ndebug1: Connecting to servera > [198.105.244.228] port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: > connect to address 198.105.244.228 port 22: Connection timed out\r\ndebug1: > Connecting to servera [198.105.254.228] port 22.\r\ndebug2: fd 3 setting > O_NONBLOCK\r\ndebug1: connect to address 198.105.254.228 port 22: > Connection timed out\r\nssh: connect to host servera port 22: Connection > timed out\r\n", "unreachable": true } to retry, use: --limit > @/home/ubuntu/playbooks/migration/main.retry > >>> > >>> PLAY RECAP > ******************************************************************************************************************************************************************************************************************************* > > > >>> 192.168.1.2 : ok=1 changed=0 unreachable=1 > failed=0 > >>> > >>> > >>> Would thank and appreciate your suggestions > >>> > >>> -- > >>> You received this message because you are subscribed to the Google > Groups "Ansible Development" group. > >>> To unsubscribe from this group and stop receiving emails from it, send > an email to ansible-deve...@googlegroups.com <javascript:>. > >>> For more options, visit https://groups.google.com/d/optout. > > > > > > -- > > You received this message because you are subscribed to the Google > Groups "Ansible Development" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to ansible-deve...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.