ansible - 如何在 Ansible 中的远程节点上执行 python 程序
问题描述
我想通过使用 Ansible 从控制节点复制 python 程序在远程节点上运行 python 程序。
我能够成功复制文件,但是它没有在远程服务器上执行 python 程序。
错误:“在 Ansible 控制器上找不到或访问 '/home/remote/files/program.py'
- name: copy the program file to ubuntu
copy:
src: /home/ubuntu/ansible/program.py
dest: /home/remote/files/program.py
mode: '0777'
when: ansible_user== 'remote'
- name: Run the python script in remote
script: /home/pi/files/program.py
args:
executable: python3
when: ansible_user== 'remote'
解决方案
使用 Shell 模块,我能够运行 python 程序。
shell:
cmd: python3 program.py
chdir: /home/ubuntu/files/
推荐阅读
- javascript - 动态生成的 PHP 下拉列表中的值不会改变
- apache-nifi - Apache NiFi PutFile 处理器未写入 Windows 共享路径
- python - 对于 df 中的每个唯一时间戳,制作数据框中所有行的向量(Python)
- scala - Nifi 和 Spark 集成
- flutter - 从名称的 String 版本调用 Dart const
- python - 我的 pandas 和 seaborn 命令没有响应
- reactjs - 为什么我的 URL ID 字符串中有多余的字符?
- google-bigquery - Firebase Analytics 应用程序和大查询计数用户
- php - 将 SQL 查询传递给 php PDO 函数并执行
- php - 对 ODBC 查找表的 PHP 代码进行故障排除