问题原文
原帖链接 · saffron · CC BY-SA 4.0
Here I am trying to invoke a python script through ansible playbook. When I run the playbook containing below mentioned code, it is successfully invoking the script. But ansible script continues to run till the Python script finishes all its Task.
- hosts: localhost
gather_facts: false
vars:
username: 'User'
password: '1234@345'
tasks:
- name: Invoking Python script
script: data_pull_push.py
args:
executable: python
The python script "data_pull_push.py" is getting data from a Url and posting it to another Url. It has too many data. So it takes really long time to retrieve and post all the data. So I want the Ansible playbook to trigger the Python script in it and close the playbook. Python script should be running in Background.
And this Ansible playbook and python script is kept in git and will be running the playbook in Ansible tower. I am not getting any idea how to use that in Ansible. If anyone knows Please let me know.
已采纳解答
原帖链接 · Alexander Tolkachev · CC BY-SA 4.0
You should use Asynchronous Actions and Polling Ansible feature.
So your task should looks like:
- name: Long async task
command: python data_pull_push.py
async: <timeout value>
poll: 0
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
