# Transfer execute and delete script python via playbook

**URL:** <https://forum.ansible.com/t/transfer-execute-and-delete-script-python-via-playbook/28234>\
**Category:** Ansible Developer\
**Created:** [August 2, 2018, 8:38am UTC](https://forum.ansible.com/t/transfer-execute-and-delete-script-python-via-playbook/28234 "2018-08-02T08:38:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Descargues](https://avatars.discourse-cdn.com/v4/letter/v/73ab20/32.png) [@Vincent\_Descargues](https://forum.ansible.com/u/Vincent_Descargues)\
**Post date:** [August 2, 2018, 8:38am UTC](https://forum.ansible.com/t/transfer-execute-and-delete-script-python-via-playbook/28234/1 "2018-08-02T08:38:38Z")

</div>

Hello,

I would like to know how it is possible with a command to be able to both transfer execute and delete a python script via a playbook. Currently I do it in 3 lines: 1) Transfer 2) Execute 3) Delete.

I could see on different forum that we could use the function “script”

My current playbook :  
hosts: host

- name: download python script  
copy:  
src: /etc/ansible/xxxx/python.py  
dest: /etc/sssd/
- name: execute python script  
command: python /etc/sssd/python.py
- name: delete python script  
command: rm /etc/sssd/python.py

In fact, I would like to be able to transfer the python script, execute it and delete it because I do not want to store it on the machine where it runs.

(example command “script” find on internet) I tried it but it does not work :

- hosts: my-servers sudo: true tasks: - script: /home/stuart/scripts/setup.sh --creates /home/stuart/installed-git.txt

Thanks a lot for answer.

Vincent
