当我通过Ansible playbook运行Python脚本时,我收到以下错误:
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/Dest/To/Repo/HW.py", "failed": true, "msg": "[Errno 13] Permission denied", "rc": 13}
我添加了sudo: yes
行:
这是我的yaml文件:
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
sudo: yes
connection: local
tasks:
- name: check out a git repository
git: repo={{ repo_url }} dest=/Dest/To/Repo/ accept_hostkey=yes
vars:
repo_url: https://github.com/lorin/mezzanine-example.git
- name: Running the Python Script
command: /Dest/To/Repo/HW.py
HW.py脚本只是print("Hello World")
关于权限错误,我需要做些什么吗?
答案 0 :(得分:2)
您需要使用umask在git模块调用中添加执行权限:
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
sudo: yes
connection: local
tasks:
- name: check out a git repository
git: repo={{ repo_url }} dest=/Dest/To/Repo/ accept_hostkey=yes
umask: 0022
vars:
repo_url: https://github.com/lorin/mezzanine-example.git