Vagrant - SSH命令以非零退出状态响应

时间:2016-11-18 14:52:13

标签: vagrant ansible ubuntu-14.04

我第一次运行此错误vagrant up。无法在执行任务时弄清楚出了什么问题:" TASK [服务器:安装额外软件包]"。 引发错误:

SSH命令以非零退出状态响应。流浪汉 假设这意味着命令失败。此命令的输出 应该在上面的日志中。请阅读输出以确定是什么 出了问题。

日志下方:

==> default: stdin: is not a tty
==> default: Ign http://archive.ubuntu.com trusty InRelease
==> default: Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
==> default: Get:2 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
==> default: Get:3 http://security.ubuntu.com trusty-security/main Sources [120 kB]
==> default: Hit http://archive.ubuntu.com trusty-backports InRelease
==> default: Hit http://archive.ubuntu.com trusty Release.gpg
==> default: Get:4 http://archive.ubuntu.com trusty-updates/main Sources [384 kB]
==> default: Get:5 http://security.ubuntu.com trusty-security/universe Sources [45.8 kB]
==> default: Get:6 http://security.ubuntu.com trusty-security/main amd64 Packages [547 kB]
==> default: Get:7 http://archive.ubuntu.com trusty-updates/restricted Sources [5,888 B]
==> default: Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [144 kB]
==> default: Get:9 http://archive.ubuntu.com trusty-updates/universe Sources [169 kB]
==> default: Get:10 http://security.ubuntu.com trusty-security/main Translation-en [301 kB]
==> default: Get:11 http://archive.ubuntu.com trusty-updates/multiverse Sources [7,522 B]
==> default: Get:12 http://archive.ubuntu.com trusty-updates/main amd64 Packages [918 kB]
==> default: Get:13 http://security.ubuntu.com trusty-security/universe Translation-en [85.0 kB]
==> default: Get:14 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [16.4 kB]
==> default: Get:15 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [388 kB]
==> default: Get:16 http://archive.ubuntu.com trusty-updates/multiverse amd64 Packages [14.0 kB]
==> default: Get:17 http://archive.ubuntu.com trusty-updates/main Translation-en [445 kB]
==> default: Get:18 http://archive.ubuntu.com trusty-updates/multiverse Translation-en [7,340 B]
==> default: Get:19 http://archive.ubuntu.com trusty-updates/restricted Translation-en [3,842 B]
==> default: Get:20 http://archive.ubuntu.com trusty-updates/universe Translation-en [205 kB]
==> default: Get:21 http://archive.ubuntu.com trusty-backports/main Sources [9,632 B]
==> default: Get:22 http://archive.ubuntu.com trusty-backports/restricted Sources [28 B]
==> default: Get:23 http://archive.ubuntu.com trusty-backports/universe Sources [35.2 kB]
==> default: Get:24 http://archive.ubuntu.com trusty-backports/multiverse Sources [1,898 B]
==> default: Hit http://archive.ubuntu.com trusty-backports/main amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/restricted amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/universe amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/multiverse amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/main Translation-en
==> default: Hit http://archive.ubuntu.com trusty-backports/multiverse Translation-en
==> default: Hit http://archive.ubuntu.com trusty-backports/restricted Translation-en
==> default: Hit http://archive.ubuntu.com trusty-backports/universe Translation-en
==> default: Hit http://archive.ubuntu.com trusty Release
==> default: Get:25 http://archive.ubuntu.com trusty/main Sources [1,064 kB]
==> default: Get:26 http://archive.ubuntu.com trusty/restricted Sources [5,433 B]
==> default: Get:27 http://archive.ubuntu.com trusty/universe Sources [6,399 kB]
==> default: Get:28 http://archive.ubuntu.com trusty/multiverse Sources [174 kB]
==> default: Hit http://archive.ubuntu.com trusty/main amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/universe amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/multiverse amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/main Translation-en
==> default: Hit http://archive.ubuntu.com trusty/multiverse Translation-en
==> default: Hit http://archive.ubuntu.com trusty/restricted Translation-en
==> default: Hit http://archive.ubuntu.com trusty/universe Translation-en
==> default: Ign http://archive.ubuntu.com trusty/main Translation-en_US
==> default: Ign http://archive.ubuntu.com trusty/multiverse Translation-en_US
==> default: Ign http://archive.ubuntu.com trusty/restricted Translation-en_US
==> default: Ign http://archive.ubuntu.com trusty/universe Translation-en_US
==> default: Fetched 11.6 MB in 10s (1,147 kB/s)
==> default: Reading package lists...
==> default: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: software-properties-common is already the newest version.
==> default: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
==> default: gpg: 
==> default: keyring `/tmp/tmp5w8ex696/secring.gpg' created
==> default: gpg: 
==> default: keyring `/tmp/tmp5w8ex696/pubring.gpg' created
==> default: gpg: 
==> default: requesting key 7BB9C367 from hkp server keyserver.ubuntu.com
==> default: gpg: 
==> default: /tmp/tmp5w8ex696/trustdb.gpg: trustdb created
==> default: gpg: 
==> default: key 7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
==> default: gpg: 
==> default: Total number processed: 1
==> default: gpg: 
==> default:               imported: 1
==> default:   (RSA: 1)
==> default: OK
==> default: Hit http://security.ubuntu.com trusty-security InRelease
==> default: Ign http://archive.ubuntu.com trusty InRelease
==> default: Get:1 http://ppa.launchpad.net trusty InRelease [16.0 kB]
==> default: Hit http://security.ubuntu.com trusty-security/main Sources
==> default: Hit http://archive.ubuntu.com trusty-updates InRelease
==> default: Hit http://security.ubuntu.com trusty-security/universe Sources
==> default: Hit http://archive.ubuntu.com trusty-backports InRelease
==> default: Get:2 http://ppa.launchpad.net trusty/main amd64 Packages [525 B]
==> default: Hit http://security.ubuntu.com trusty-security/main amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty Release.gpg
==> default: Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
==> default: Get:3 http://ppa.launchpad.net trusty/main Translation-en [322 B]
==> default: Hit http://archive.ubuntu.com trusty-updates/main Sources
==> default: Hit http://security.ubuntu.com trusty-security/main Translation-en
==> default: Hit http://archive.ubuntu.com trusty-updates/restricted Sources
==> default: Hit http://security.ubuntu.com trusty-security/universe Translation-en
==> default: Hit http://archive.ubuntu.com trusty-updates/universe Sources
==> default: Hit http://archive.ubuntu.com trusty-updates/multiverse Sources
==> default: Hit http://archive.ubuntu.com trusty-updates/main amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-updates/restricted amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-updates/universe amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-updates/multiverse amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-updates/main Translation-en
==> default: Hit http://archive.ubuntu.com trusty-updates/multiverse Translation-en
==> default: Hit http://archive.ubuntu.com trusty-updates/restricted Translation-en
==> default: Hit http://archive.ubuntu.com trusty-updates/universe Translation-en
==> default: Hit http://archive.ubuntu.com trusty-backports/main Sources
==> default: Hit http://archive.ubuntu.com trusty-backports/restricted Sources
==> default: Hit http://archive.ubuntu.com trusty-backports/universe Sources
==> default: Hit http://archive.ubuntu.com trusty-backports/multiverse Sources
==> default: Hit http://archive.ubuntu.com trusty-backports/main amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/restricted amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/universe amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/multiverse amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty-backports/main Translation-en
==> default: Hit http://archive.ubuntu.com trusty-backports/multiverse Translation-en
==> default: Hit http://archive.ubuntu.com trusty-backports/restricted Translation-en
==> default: Hit http://archive.ubuntu.com trusty-backports/universe Translation-en
==> default: Hit http://archive.ubuntu.com trusty Release
==> default: Hit http://archive.ubuntu.com trusty/main Sources
==> default: Hit http://archive.ubuntu.com trusty/restricted Sources
==> default: Hit http://archive.ubuntu.com trusty/universe Sources
==> default: Hit http://archive.ubuntu.com trusty/multiverse Sources
==> default: Hit http://archive.ubuntu.com trusty/main amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/universe amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/multiverse amd64 Packages
==> default: Hit http://archive.ubuntu.com trusty/main Translation-en
==> default: Hit http://archive.ubuntu.com trusty/multiverse Translation-en
==> default: Hit http://archive.ubuntu.com trusty/restricted Translation-en
==> default: Hit http://archive.ubuntu.com trusty/universe Translation-en
==> default: Ign http://archive.ubuntu.com trusty/main Translation-en_US
==> default: Ign http://archive.ubuntu.com trusty/multiverse Translation-en_US
==> default: Ign http://archive.ubuntu.com trusty/restricted Translation-en_US
==> default: Ign http://archive.ubuntu.com trusty/universe Translation-en_US
==> default: Fetched 16.8 kB in 4s (3,720 B/s)
==> default: Reading package lists...
==> default: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: The following extra packages will be installed:
==> default:   python-jinja2 python-markupsafe python-paramiko python-setuptools sshpass
==> default: Suggested packages:
==> default:   python-jinja2-doc
==> default: The following NEW packages will be installed:
==> default:   ansible python-jinja2 python-markupsafe python-paramiko python-setuptools
==> default:   sshpass
==> default: 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
==> default: Need to get 2,129 kB of archives.
==> default: After this operation, 15.0 MB of additional disk space will be used.
==> default: Get:1 http://ppa.launchpad.net/ansible/ansible/ubuntu/ trusty/main ansible all 2.2.0.0-1ppa~trusty [1,608 kB]
==> default: Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main python-markupsafe amd64 0.18-1build2 [14.3 kB]
==> default: Get:3 http://archive.ubuntu.com/ubuntu/ trusty/main python-jinja2 all 2.7.2-2 [161 kB]
==> default: Get:4 http://archive.ubuntu.com/ubuntu/ trusty/main python-paramiko all 1.10.1-1git1build1 [106 kB]
==> default: Get:5 http://archive.ubuntu.com/ubuntu/ trusty-updates/main python-setuptools all 3.3-1ubuntu2 [230 kB]
==> default: Get:6 http://archive.ubuntu.com/ubuntu/ trusty/universe sshpass amd64 1.05-1 [10.5 kB]
==> default: dpkg-preconfigure: unable to re-open stdin: No such file or directory
==> default: Fetched 2,129 kB in 1s (2,109 kB/s)
==> default: Selecting previously unselected package python-markupsafe.
==> default: (Reading database ... 63004 files and directories currently installed.)
==> default: Preparing to unpack .../python-markupsafe_0.18-1build2_amd64.deb ...
==> default: Unpacking python-markupsafe (0.18-1build2) ...
==> default: Selecting previously unselected package python-jinja2.
==> default: Preparing to unpack .../python-jinja2_2.7.2-2_all.deb ...
==> default: Unpacking python-jinja2 (2.7.2-2) ...
==> default: Selecting previously unselected package python-paramiko.
==> default: Preparing to unpack .../python-paramiko_1.10.1-1git1build1_all.deb ...
==> default: Unpacking python-paramiko (1.10.1-1git1build1) ...
==> default: Selecting previously unselected package python-setuptools.
==> default: Preparing to unpack .../python-setuptools_3.3-1ubuntu2_all.deb ...
==> default: Unpacking python-setuptools (3.3-1ubuntu2) ...
==> default: Selecting previously unselected package sshpass.
==> default: Preparing to unpack .../sshpass_1.05-1_amd64.deb ...
==> default: Unpacking sshpass (1.05-1) ...
==> default: Selecting previously unselected package ansible.
==> default: Preparing to unpack .../ansible_2.2.0.0-1ppa~trusty_all.deb ...
==> default: Unpacking ansible (2.2.0.0-1ppa~trusty) ...
==> default: Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
==> default: Setting up python-markupsafe (0.18-1build2) ...
==> default: Setting up python-jinja2 (2.7.2-2) ...
==> default: Setting up python-paramiko (1.10.1-1git1build1) ...
==> default: Setting up python-setuptools (3.3-1ubuntu2) ...
==> default: Setting up sshpass (1.05-1) ...
==> default: Setting up ansible (2.2.0.0-1ppa~trusty) ...
==> default: [DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and 
==> default: make sure become_method is 'sudo' (default).
==> default: This feature will be removed in a 
==> default: future release. Deprecation warnings can be disabled by setting 
==> default: deprecation_warnings=False in ansible.cfg.
==> default: 
==> default: PLAY [all] *********************************************************************
==> default: 
==> default: TASK [setup] *******************************************************************
==> default: ok: [192.168.10.15]
==> default: 
==> default: TASK [server : Update apt] *****************************************************
==> default: changed: [192.168.10.15]
==> default: 
==> default: TASK [server : Install System Packages] ****************************************
==> default: changed: [192.168.10.15] => (item=[u'curl', u'wget', u'python-software-properties'])
==> default: 
==> default: TASK [server : Install Extra Packages] *****************************************
==> default: failed: [192.168.10.15] (item=[u'server.packages']) => {"failed": true, "item": ["server.packages"], "msg": "No package matching 'server.packages' is available"}
==> default:    to retry, use: --limit @/vagrant/ansible/playbook.retry
==> default: 
==> default: PLAY RECAP *********************************************************************
==> default: 192.168.10.15              : ok=3    changed=2    unreachable=0    failed=1   
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
出现了

main.yml" server.packages"

- name: Install Extra Packages
  sudo: yes
  apt: pkg={{ item }} state=latest
  with_items: server.packages
  when: server.packages is defined

虚拟机来自Phansible.com内置的配置

1 个答案:

答案 0 :(得分:3)

最后的Vagrant消息只报告会话以非零返回码结束。返回代码的原因是:

==> default: failed: [192.168.10.15] (item=[u'server.packages']) => {"failed": true, "item": ["server.packages"], "msg": "No package matching 'server.packages' is available"}
==> default:    to retry, use: --limit @/vagrant/ansible/playbook.retry

我的猜测是你想从变量中扩展server.packages。即。

with_items: '{{server.packages}}'

而不是

with_items: server.packages

with_items:
- server.packages

请参阅Ansible Porting Guide, Deprecated section