我想使用
Vagrant测试
Ansible脚本.一切正常,直到它尝试对远程主机执行rsync:
- name: Install custom dev user settings local_action: command rsync -ave ssh roles/common/files/home/{{ item.name }} {{ ansible_ssh_user }}@{{ inventory_hostname }}:/#home/ with_items: dev_users when: "{{ item.custom }} == True" tags: - dev_custom - dev_users - users
然而它在这一点上失败了 – 它似乎试图通过密码登录,但我不知道为什么它应该通过SSH连接到Vagrant,对(我已经在下面省略了一些信息……因为它提到了密钥)?
127.0.0.1> EXEC ['/bin/sh','-c','mkdir -p $HOME/.ansible/tmp/ansible-1393178896.64-215542007508316 && chmod a+rx $HOME/.ansible/tmp/ansible-1393178896.64-215542007508316 && echo $HOME/.ansible/tmp/ansible-1393178896.64-215542007508316'] <127.0.0.1> REMOTE_MODULE command rsync -ave ssh roles/common/files/home/someUser vagrant@10.0.0.10:/#home/ <127.0.0.1> PUT /tmp/tmpm3BnEW TO /home/mark/.ansible/tmp/ansible-1393178896.64-215542007508316/command <127.0.0.1> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible,key=...] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-...; /usr/bin/python /home/mark/.ansible/tmp/ansible-1393178896.64-215542007508316/command; rm -rf /home/mark/.ansible/tmp/ansible-1393178896.64-215542007508316/ >/dev/null 2>&1'"'"'' Failed: [10.0.0.10] => (item={ ... }) => {"Failed": true,"item": { ... },"parsed": false} invalid output was: [sudo via ansible,key=...] password: [sudo via ansible,key=...] password: Sorry,try again. [sudo via ansible,try again. sudo: 3 incorrect password attempts
知道怎么解决这个问题吗?
在我这样做之前,我通过ansible在盒子上部署了一个自定义键,例如:
- name: Place ansible authorized key authorized_key: user=root key="{{ lookup('file','root/.ssh/ansible_key.pub') }}" tags: - root