Execute Python file in remore machines

23 views
Skip to first unread message

Amrit Bhandari

unread,
Jul 20, 2016, 10:53:21 AM7/20/16
to Ansible Project
Hello everyone,
           I am new to Ansible.I have been trying to execute a Python script in remote nodes however am confused how to do it.I wrote a playbook and tried to execute it however I get some errors.I am using Fedora Linux and  Ansible 2.1.0 in a college lab environment and trying to connect 5 nodes.

Here's my Playbook

# bootstrap.yml
---
- hosts: all


  tasks:
  - name: Copy file
    copy:  src=/usr10/bhandara/Desktop/PythonDriver-master/client/modeling2_client.py dest=/home/test_user/modeling2_client.py

  - name: Execute script
    command: /home/test_user/modeling2_client.py


I get the following error when I try to execute it:

TASK [Copy file] ***************************************************************
fatal: [jazz923.cs.lafayette.edu]: FAILED! => {"changed": false, "checksum": "97a618f74393c38eb5c6190523c93c0daeffb47c", "failed": true, "msg": "Destination directory /home/test_user does not exist"}
fatal: [jazz917.cs.lafayette.edu]: FAILED! => {"changed": false, "checksum": "97a618f74393c38eb5c6190523c93c0daeffb47c", "failed": true, "msg": "Destination directory /home/test_user does not exist"}
fatal: [jazz924.cs.lafayette.edu]: FAILED! => {"changed": false, "checksum": "97a618f74393c38eb5c6190523c93c0daeffb47c", "failed": true, "msg": "Destination directory /home/test_user does not exist"}
fatal: [jazz902.cs.lafayette.edu]: FAILED! => {"changed": false, "checksum": "97a618f74393c38eb5c6190523c93c0daeffb47c", "failed": true, "msg": "Destination directory /home/test_user does not exist"}
fatal: [jazz901.cs.lafayette.edu]: FAILED! => {"changed": false, "checksum": "97a618f74393c38eb5c6190523c93c0daeffb47c", "failed": true, "msg": "Destination directory /home/test_user does not exist"}

I'd be obliged if someone could tell me what kind of directory we need to make in remote machines.

Kai Stian Olstad

unread,
Jul 20, 2016, 11:56:30 AM7/20/16
to ansible...@googlegroups.com
On 19. juli 2016 19:47, Amrit Bhandari wrote:
> Here's my Playbook
>
> # bootstrap.yml
> ---
> - hosts: all
>
>
> tasks:
> - name: Copy file
> copy:
> src=/usr10/bhandara/Desktop/PythonDriver-master/client/modeling2_client.py
> dest=/home/test_user/modeling2_client.py
>
> - name: Execute script
> command: /home/test_user/modeling2_client.py
>
>
> I get the following error when I try to execute it:
>
> TASK [Copy file]
> ***************************************************************
> fatal: [jazz923.cs.lafayette.edu]: FAILED! => {"changed": false,
> "checksum": "97a618f74393c38eb5c6190523c93c0daeffb47c", "failed": true,
> "msg": "Destination directory /home/test_user does not exist"}

>
> I'd be obliged if someone could tell me what kind of directory we need to
> make in remote machines.

The error message clearly state which one,
"Destination directory /home/test_user does not exist"

When you are copying file the destination directory need to exist.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages