2013-09-21 58 views
10

Tôi đã kéo xuống một repo git và chạy lang thang lên nhưng tôi nhận được thông báo lỗi nàylang thang ansible Các cài đặt sau không tồn tại: inventory_file

The following settings don't exist: inventory_file 

Tôi đã cài đặt hộp ảo và lang thang và ansible cho sư tử núi osx.

Nhưng tôi không thể làm gì cả.

cũng có khi tôi chạy ansible all -m ping -vvvv tôi nhận được

<192.168.0.62> ESTABLISH CONNECTION FOR USER: Grant 
<192.168.0.62> EXEC ['ssh', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/Grant/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', '192.168.0.62', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-1379790346.17-244145524385544 && chmod a+rx $HOME/.ansible/tmp/ansible-1379790346.17-244145524385544 && echo $HOME/.ansible/tmp/ansible-1379790346.17-244145524385544'"] 
192.168.0.62 | FAILED => SSH encountered an unknown error. The output was: 
OpenSSH_5.9p1, OpenSSL 0.9.8y 5 Feb 2013 
debug1: Reading configuration data /etc/ssh_config 
debug1: /etc/ssh_config line 20: Applying options for * 
debug1: auto-mux: Trying existing master 
debug1: Control socket "/Users/Grant/.ansible/cp/ansible-ssh-192.168.0.62-22-Grant" does not exist 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to 192.168.0.62 [192.168.0.62] port 22. 
debug2: fd 3 setting O_NONBLOCK 
debug1: connect to address 192.168.0.62 port 22: Operation timed out 
ssh: connect to host 192.168.0.62 port 22: Operation timed out 

Bất kỳ ý tưởng về những gì đang xảy ra sẽ được đánh giá cao :)

Trả lời

11

Đối với vấn đề inventory_file hãy thử thay đổi Vagrantfile sử dụng inventory_path để thay thế. Tôi nghĩ rằng sự thay đổi tinh tế này xảy ra với Vagrant 1.3.x. Nếu bạn không muốn sửa đổi số Vagrantfile hãy thử sử dụng Vagrant 1.2.x.

Khi chạy:

ansible all -m ping -vvvv 

này sẽ sử dụng người dùng hiện tại của bạn và sẽ xem xét trong vị trí mặc định cho đội chủ nhà kiểm kê Ansible (/etc/ansible/hosts).

Để làm cho nó hoạt động với Máy ảo được xác định theo Vagrant, bạn cần sử dụng người dùng vagrant, chỉ định khóa SSH để sử dụng trong khi kết nối và chỉ định vị trí của khoảng không quảng cáo lưu trữ, ví dụ:

ansible all \ 
    -i provisioning/inventory # <-- or wherever the inventory is \ 
    -m ping \ 
    -u vagrant \ 
    --private-key ~/.vagrant.d/insecure_private_key 
0

Thay vì chuyển inventory_file, private_key và ssh_user mỗi lần, bạn có thể đưa chúng vào tệp cấu hình không thể đọc. Xem câu trả lời chi tiết hơn của tôi ở đây: https://stackoverflow.com/a/25316963/502457

0
$ ansible all -i inventory -m ping -u vagrant --private-key ~/.vagrant.d/insecure_private_key 
ansible_ssh_private_key_file=/Users/dxiao/.vagrant.d/insecure_private_key | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue 
ansible_ssh_user=vagrant | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue 
testserver | success >> { 
    "changed": false, 
    "ping": "pong" 
} 

$ cat inventory 
testserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 
ansible_ssh_user=vagrant 
ansible_ssh_private_key_file=/Users/dxiao/.vagrant.d/insecure_private_key 

hoạt động.

3

Nó đã được lặp lại trên toàn bộ khối về việc sử dụng ~/.vagrant.d/insecure_private_key nhưng tôi thấy rằng nó đang sử dụng thực tế .vagrant/machines/default/virtualbox/private_key, trong đường dẫn nơi Vagrantfile là. Họ có thể đã thay đổi thế hệ quan trọng của mình thành từng máy, không phải trên toàn người dùng, nhưng tài liệu không phản ánh điều đó.

Vì vậy, đối với toàn bộ lệnh, nó sẽ là:

ansible-playbook -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory --private-key=.vagrant/machines/default/virtualbox/private_key -u vagrant playbook.yml

Bạn có thể kiểm tra xem là một hay khác bằng cách chạy vagrant ssh-config và tìm kiếm các giá trị IdentityFile.