2017-05-12 2 views
2

Ich versuche, Ubuntu mit Vagrant und Ansible bereitzustellen. Ich arbeite mit this article und drücke den unten gezeigten Fehler.Vagrant Provisioning mit Ansible schlägt fehl

________________________ 
< TASK [Gathering Facts] > 
------------------------ 
     \ ^__^ 
     \ (oo)\_______ 
      (__)\  )\/\ 
       ||----w | 
       ||  || 

fatal: [default]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", "msg": "MODULE FAILURE", "rc": 0} 
to retry, use: --limit @/Users/tomoya/vagrant-project/playbook.retry 
____________ 
< PLAY RECAP > 
------------ 
     \ ^__^ 
     \ (oo)\_______ 
      (__)\  )\/\ 
       ||----w | 
       ||  || 

default     : 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. 

Struktur Meine Auswahl lautet:

vagrant-project 
├── Vagrantfile 
└── playbook.yml 

Vagrantfile enthält:

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

Vagrant.configure("2") do |config| 
    config.vm.box = "ubuntu/xenial64" 
    config.vm.network "forwarded_port", guest: 80, host: 8080 
    config.vm.provision :ansible do |ansible| 
    ansible.playbook = "playbook.yml" 
    end 
end 

playbook.yml enthält:

--- 
- hosts: all 
    sudo: true 
    tasks: 
    - name: update apt cache 
     apt: update_cache=yes 
    - name: install apache 
     apt: name=apache2 state=present 
    - name: install mysql 
     apt: name=mysql-server state=present 
    - name: install php 
     apt: name=php5 state=present 

Ich verwende:

  • Vagrant 1.9.4
  • VirtualBox 5.1.22
  • ansible 2.3.0.0

Sie sind fast identisch mit den im Artikel gezeigten Codes. Könnten Sie mir bitte sagen, was falsch ist und wie ich es erfolgreich bereitstellen könnte?

Danke.

+0

Es gibt eine Fehlermeldung in der Ausgabe: 'module_stdout ':"/bin/sh: 1:/usr/bin/python: nicht gefunden ". –

+0

http://stackoverflow.com/questions/43678361/vagrant-ansible-provisioner-throwing-error-module-failure-when-running-playboo/43678427#43678427 ist auch über die gleichen –

Antwort

4

Wie Konstantin Suworow erwähnt, ist es ein mögliches Duplikat des erwähnten Posts. Um Ihre Frage zu beantworten, wenn ansible auf einem entfernten Host ausgeführt wird, wird standardmäßig python als verfügbar in/usr/bin/python angezeigt. Aber in Ubuntu 16.04 /usr/bin/Python ist nicht verfügbar und nur/usr/bin/python3 oder /usr/bin/python3.5 ist verfügbar.

Wir können dieses Problem auf zwei Arten überwinden,

1) Installieren python2 die Rohmodul im pre_tasks Abschnitt verwenden, bevor ansible Aufgaben starten, so/usr/bin/python verfügbar ist. Das Textbuch würde dann

--- 
- hosts: all 
    sudo: true 
    gather_facts: False 

    pre_tasks: 
    - raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) 
    - setup: 

    tasks: 
    - name: update apt cache 
     apt: update_cache=yes 
    - name: install apache 
     apt: name=apache2 state=present 
    - name: install mysql 
     apt: name=mysql-server state=present 
    - name: install php 
     apt: name=php5 state=present 

Oder

2) würde ansible_python_interpeter variabel und in diesem Fall die Python-Pfad Geben Sie mithilfe der Vagabund-Datei werden

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

Vagrant.configure("2") do |config| 
    config.vm.box = "ubuntu/xenial64" 
    config.vm.network "forwarded_port", guest: 80, host: 8080 
    config.vbguest.auto_update = false 
    config.vm.provision :ansible do |ansible| 
    ansible.playbook = "playbook.yml" 
    ansible.extra_vars = { 
     ansible_python_interpreter: "/usr/bin/python3.5", 
    } 
    end 
end 
+0

Vielen Dank! Deine Antwort hat mein Problem gelöst :) – Tomoya

Verwandte Themen