---
- hosts: all
become: true
become_user: root
become_method: sudo
gather_facts: False
tasks:
- name: Root user check
shell : export PATH=$HOME/python/Python-2.7.12:$PATH;export PYTHONPATH=$HOME/python/Python-2.7.12;python --version;whoami
我正在从用户A在远程服务器上运行上述剧本。
远程服务器上 userA 的配置如下
用户A ALL=(全部) NOPASSWD:ALL
关于我遗漏了什么,有什么指示吗?
我遇到的错误如下
Sorry, user userA is not allowed to execute ‘/bin/sh -c echo BECOME-SUCCESS-ltfjopjkdxnxjqhkpmgpokjgki; /usr/bin/python /home/userA/.ansible/tmp/ansible-tmp-1597841138.97-224625741903296/command.py’ as root on server
我尝试保留远程 ansible 文件,然后从远程服务器手动运行 command.py,它可以工作