我想用Vagrant來測試Ansible腳本。一切工作正常,直到它試圖做一個rsync的遠程主機:讓Ansible中的rsync與Vagrant一起工作
- 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的流浪者,正確(我已經在下面忽略了一些信息,因爲它提到了密鑰)?
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 [email protected]:/#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, key=...] password:
[sudo via ansible, key=...] password:
Sorry, try again.
[sudo via ansible, key=...] password:
[sudo via ansible, key=...] password:
Sorry, 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
是的馬克,但似乎你正在部署你的密鑰〜根/ .ssh,而你連接爲'流浪'。 – leucos
沒關係Leucos,你是一個很大的幫助 - 這個Ansible教程看起來不錯https://github.com/leucos/ansible-tuto,所以我會通過這個接下來的工作。謝謝! –
不客氣,盡情玩樂 – leucos