Ansible&找不到Vagrant - apt-get:命令

时间:2014-05-23 04:21:45

标签: vagrant ansible ansible-playbook vagrantfile

我是使用Vagrant和Ansible的新手。目前我被困在Ansible上,告诉我它无法找到apt-get命令。

My Vagrant框在Ubuntu上运行,以下是相关文件:

// Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"
  config.vm.network :private_network, :ip => "192.168.33.10"

  # make sure apt repo is up to date
  config.vm.provision :shell, :inline => 'apt-get -qqy update'

  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yml"
  end
end



// vagrant_ansible_inventory_default
# Generated by Vagrant

default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222



// playbook.yml
---
- name: Install MySQL, Nginx, Node.js, and Monit
  hosts: 127.0.0.1
  user: root
  # remote_user: user
  # sudo: yes

  roles:
    - nginx



// roles/nginx/tasks/main.yml
---
- name: Installs nginx web server
  apt: pkg=nginx state=installed update_cache=true
  notify:
    - start nginx

当我运行vagrant provision时,我得到了

[default] Running provisioner: shell...
[default] Running: inline script
stdin: is not a tty
[default] Running provisioner: ansible...

PLAY [Install MySQL, Nginx, Node.js, and Monit] *******************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [nginx | Installs nginx web server] *************************************
failed: [127.0.0.1] => {"cmd": "apt-get update && apt-get install python-apt -y -q",
    "failed": true, "item": "", "rc": 127}

stderr: /bin/sh: apt-get: command not found

msg: /bin/sh: apt-get: command not found

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/foosbar/playbook.retry

127.0.0.1                  : ok=1    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.

我错过了什么?

1 个答案:

答案 0 :(得分:1)

如果您针对实际分配给流浪者的IP地址运行游戏会怎样?

// playbook.yml
---
- name: Install MySQL, Nginx, Node.js, and Monit
  hosts: 192.168.33.10

您想要播放该剧的主持人是流浪汉。在这种情况下,hosts不是指主节点,而是节点。