How to execute a shell script on a remote server using Ansible?
问题 I am planning to execute a shell script on a remote server using Ansible playbook. test.sh: touch test.txt Playbook: --- - name: Transfer and execute a script. hosts: server user: test_user sudo: yes tasks: - name: Transfer the script copy: src=test.sh dest=/home/test_user mode=0777 - name: Execute the script local_action: command sudo sh /home/test_user/test.sh When I run the playbook, the transfer successfully occurs but the script is not executed. 回答1: local_action runs the command on the