首页 > 解决方案 > 在 easy_install 中被 ansible 提示输入 ssh 密码

问题描述

团队,我需要使用我的 macbook 抱怨需要 dnspython 的 dig 模块。所以我用easy_install安装它,但提示输入密码。如何使其无密码?

      - easy_install:
          name: dnspython
          state: present
        become: yes

      - name: Validate DNS record lookup for {{ kubeapi_server }}
        debug: msg="{{ lookup('dig', '{{ kubeapi_server }}' )}}"
        vars:
          variable: "{{ lookup('dig', '{{ kubeapi_server }}' )}}"
        failed_when: not variable

输出 1:带 -k 选项

ansible-playbook -i inventory.txt playbook.yaml -k -K
SSH password: 
BECOME password[defaults to SSH password]: 

输出 1:没有 -k -K 选项

ansible-playbook -i inventory.txt playbook.yaml
TASK [0_test : easy_install] ***************************
fatal: [target1]: FAILED! => {"changed": false, "msg": "error: can't create or remove files in install directory\n\nThe following error occurred while trying to add or remove files in the\ninstallation directory:\n\n    [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-68421.pth'\n\nThe installation directory you specified (via --install-dir, --prefix, or\nthe distutils default setting) was:\n\n    /Library/Python/2.7/site-packages/\n\nPerhaps your account does not have write access to this directory?  If the\ninstallation directory is a system-owned directory, you may need to sign in\nas the administrator or \"root\" account.  If you do not have administrative\naccess to this machine, you may wish to choose a different installation\ndirectory, preferably one that is listed in your PYTHONPATH environment\nvariable.\n\nFor information on other options, you may wish to consult the\ndocumentation at:\n\n  https://pythonhosted.org/setuptools/easy_install.html\n\nPlease make the appropriate changes for your system and try again.\n\n"}

标签: ansibleansible-2.xansible-facts

解决方案


可能的原因可能是: 1.您没有在主机清单中指定密码。2. 用户的 sudo 权限应该是 NOPASSWD: ALL 在主机的 /etc/sudoers 中。


推荐阅读