2017-02-25 2 views
1

Ich möchte mit meinen drei Knoten von der letzten mit Hilfe von Ansible bereitstellen.Ansible Provisioning FEHLER! Die Verwendung eines SSH-Passworts anstelle eines Schlüssels ist nicht möglich

Meine Host-Rechner ist Windows-10

Mein Vagrantfile wie folgt aussieht:

Vagrant.configure("2") do |config| 

    (1..3).each do |index| 
    config.vm.define "node#{index}" do |node| 

     node.vm.box = "ubuntu" 
     node.vm.box = "../boxes/ubuntu_base.box" 

     node.vm.network :private_network, ip: "192.168.10.#{10 + index}" 

     if index == 3 
     node.vm.provision :setup, type: :ansible_local do |ansible| 
      ansible.playbook = "playbook.yml" 
      ansible.provisioning_path = "/vagrant/ansible" 
      ansible.inventory_path = "/vagrant/ansible/hosts" 
      ansible.limit = :all 
      ansible.install_mode = :pip 
      ansible.version = "2.0" 
     end 
     end 

    end 
    end 

end 

Mein Textbuch wie folgt aussieht:

--- 

# my little playbook 

- name: My little playbook 
    hosts: webservers 
    gather_facts: false 
    roles: 
    - create_user 

Meine hosts-Datei wie folgt aussieht:

[webservers] 
192.168.10.11 
192.168.10.12 

[dbservers] 
192.168.10.11 
192.168.10.13 

[all:vars] 
ansible_connection=ssh 
ansible_ssh_user=vagrant 
ansible_ssh_pass=vagrant 

Af ter vagrant up --provision Ausführung bekam ich folgende Fehlermeldung:

Bringing machine 'node1' up with 'virtualbox' provider... 
Bringing machine 'node2' up with 'virtualbox' provider... 
Bringing machine 'node3' up with 'virtualbox' provider... 
==> node3: Running provisioner: setup (ansible_local)... 
    node3: Running ansible-playbook... 

PLAY [My little playbook] ****************************************************** 

TASK [create_user : Create group] ********************************************** 
fatal: [192.168.10.11]: FAILED! => {"failed": true, "msg": "ERROR! Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."} 
fatal: [192.168.10.12]: FAILED! => {"failed": true, "msg": "ERROR! Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."} 

PLAY RECAP ********************************************************************* 
192.168.10.11    : ok=0 changed=0 unreachable=0 failed=1 
192.168.10.12    : ok=0 changed=0 unreachable=0 failed=1 

Ansible failed to complete successfully. Any error output should be 
visible above. Please fix these errors and try again. 

ich mit ansible.limit = :all meine Vagrantfile erweitert und [all:vars] zum Hostfile hinzugefügt, aber noch nicht durch den Fehler.

Hat jemand das gleiche Problem festgestellt?

Antwort

7

Erstellen Sie eine Datei ansible/ansible.cfg in Ihrem Projektverzeichnis (dh ansible.cfg in der provisioning_path auf dem Ziel) mit folgendem Inhalt:

[defaults] 
host_key_checking = false 

vorausgesetzt, dass Ihr Vagrant Box sshpass bereits installiert ist - es ist unklar, da die Fehlermeldung in Ihrer Frage schon sagt es installiert wurde (sonst wäre es "ERROR sein! die ‚ssh‘ Verbindungsart mit Passwörtern zu verwenden, müssen Sie das sshpass Programm „) installieren, aber in your answer Sie es explizit hinzufügen (sudo apt-get install sshpass), wie es nicht

+0

yep, das funktioniert! Brauchen Sie nicht die Abhilfe! – Mark

4

Diese SO post gab die Antwort.

I erweitert gerade die known_hosts-Datei auf der Maschine, die für die Bereitstellung wie diese verantwortlich ist:

Snippet von meinem modifizierten Vagrantfile:

... 
if index == 3 
    node.vm.provision :pre, type: :shell, path: "install.sh" 

    node.vm.provision :setup, type: :ansible_local do |ansible| 
... 

Mein install.sh wie folgt aussieht:

# add web/database hosts to known_hosts (IP is defined in Vagrantfile) 
ssh-keyscan -H 192.168.10.11 >> /home/vagrant/.ssh/known_hosts 
ssh-keyscan -H 192.168.10.12 >> /home/vagrant/.ssh/known_hosts 
ssh-keyscan -H 192.168.10.13 >> /home/vagrant/.ssh/known_hosts 
chown vagrant:vagrant /home/vagrant/.ssh/known_hosts 

# reload ssh in order to load the known hosts 
/etc/init.d/ssh reload 
+1

shellscripting Abhilfe war. ansible obwohl eine bessere Art und Weise gewährleistet! – Mark

Verwandte Themen