2013-09-21 4 views
10

inventory_file मैं एक Git रेपो नीचे खींच लिया है और ऊपर आवारा भाग गया, लेकिन मैंआवारा ansible निम्न सेटिंग्स मौजूद नहीं हैं:

The following settings don't exist: inventory_file 

मैं आभासी बॉक्स और आवारा और स्थापित किया है इस त्रुटि संदेश मिल रहा ओएसएक्स पर्वत शेर के लिए उत्तरदायी।

लेकिन मुझे काम करने के लिए कुछ भी नहीं मिल सकता है।

भी जब मैं ansible all -m ping -vvvv चलाने मैं

<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 

क्या सराहना की जाएगी चल रहा है पर कोई भी विचार :)

उत्तर

11

inventory_file मुद्दे के लिए Vagrantfile बदलते बजाय inventory_path इस्तेमाल करने की कोशिश मिलता है। मुझे लगता है कि यह सूक्ष्म परिवर्तन Vagrant 1.3.x के साथ हुआ था। यदि आप Vagrantfile को संशोधित नहीं करना चाहते हैं तो Vagrant 1.2.x का उपयोग करने का प्रयास करें।

जब चल रहा है:

ansible all -m ping -vvvv 

यह आपके वर्तमान उपयोगकर्ता का उपयोग करेगा और Ansible मेजबान सूची (/etc/ansible/hosts) के लिए डिफ़ॉल्ट स्थान में दिखेगा।

आदेश में यह एक Vagrant के साथ काम करने के लिए वी एम परिभाषित आप vagrant उपयोगकर्ता का उपयोग करें, कनेक्शन के दौरान उपयोग करने के लिए SSH कुंजी निर्दिष्ट और मेजबान सूची, उदा का स्थान निर्दिष्ट करने की जरूरत है

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

इसके बजाय inventory_file, private_key और ssh_user हर बार उत्तीर्ण होने की, तो आप एक ansible कॉन्फ़िग फ़ाइल में उन डाल सकते हैं। यहां मेरा अधिक विस्तृत उत्तर देखें: 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 

यह काम करता है।

3

~/.vagrant.d/insecure_private_key का उपयोग करने के बारे में सभी ब्लॉक को दोहराया गया है, लेकिन मुझे पता चला कि यह वास्तव में .vagrant/machines/default/virtualbox/private_key का उपयोग कर रहा था, जहां Vagrantfile है। उन्होंने शायद अपनी मुख्य पीढ़ी को प्रति-मशीन होने के लिए बदल दिया, उपयोगकर्ता-व्यापी नहीं, लेकिन दस्तावेज अभी तक इसे प्रतिबिंबित नहीं करता है।

तो पूरे आदेश के लिए, यह होगा:

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

आप देख सकते हैं एक या vagrant ssh-config चल रहा है और IdentityFile मूल्य की तलाश द्वारा अन्य है या नहीं।

संबंधित मुद्दे