小编Arc*_*der的帖子

使用ansible在远程服务器上执行python脚本错误

我使用 ansible 2.8.3 Rhel 8 以 root@xxx12 身份登录。
我希望将一些文件复制到 root@xxx13 Rhel 8,然后执行 python 脚本。
我能够使用 ansible成功复制文件。我什至复制了密钥,现在它不再需要 ssh。

但在执行脚本期间:'致命:[web_node1]:失败!=> {"changed": false, "msg": "无法在 Ansible 控制器上找到或访问 '/root/ansible_copy/write_file.py'。\n如果您正在使用模块并期望该文件存在于远程,请参阅remote_src选项“}'
请注意,我是ansible的新手。
我猜有一些权限问题。
如果可能的话请帮助我。期待中的感谢

**yaml_file**
-
    name: Copy_all_ansible_files_to_servers
    hosts: copy_Servers
    become: true
    become_user: root
    tasks:
    -
      name: copy_to_all
      copy:
       src: /home/testuser/ansible_project/{{item}}
       dest: /root/ansible_copy/{{item}}
       owner: root
       group: root
       mode: u=rxw,g=rxw,o=rxw
      with_items:
         - write_file.py
         - sink.txt
         - ansible_playbook_task.yaml
         - copy_codes_2.yaml
      notify :
           - Run_date_command

    -
      name: Run_python_script
      script: /root/ansible_copy/write_file.py > /root/ansible_copy/sink.txt
      args:
        #chdir: '{{ role_path }}' …
Run Code Online (Sandbox Code Playgroud)

ansible ansible-inventory

2
推荐指数
1
解决办法
7266
查看次数

标签 统计

ansible ×1

ansible-inventory ×1