I am planning to execute a python script on a remote server using ansible 
playbook.

    src.py -
    ---------
    import os, sys

    if __name__ == '__main__':
        os.system('touch test.txt')
        sys.exit()

    playbook -
    ----------
    ---
    - name: Transfer and execute a script.
      hosts: server
      user: test_user
      sudo: yes
      tasks:
         - name: Transfer the script
           copy: src=src.py dest=/home/test_user mode=0777
  
         - name: Execute the script
           local_action: command sudo python /home/test_user/src.py
 
When I run the playbook, the transfer successfully occurs. But the script 
is not executed. I also tried transferring to a different directory /tmp, 
shell and raw module but it didn't work.

Any help is appreciated.

Thanks,

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to