Ansible无法找到requirements.txt

时间:2017-02-27 18:16:22

标签: ubuntu vagrant pip ansible

我的目录结构是这样的

$ tree
├── Vagrantfile
├── files
│   ├── cmake
│   ├── pip-requirements.txt
│   └── profile
└── tasks
    └── main.yml

main.yml

的内容
---
- hosts: kurseve
  tasks:
      - name: Install pip
        pip:
          requirements: ../files/pip-requirements.txt
          virtualenv: /home/vagrant/venvs/cv
          virtualenv_python: python2.7

但是当我尝试使用项目根目录中的vagrant up --provision命令配置Vagrant框时。错误日志显示ansible无法找到放置在pip-requirements.txt

内的files/

这是错误日志

fatal: [kurseve]: FAILED! => {
    "changed": false,
    "cmd": "/home/vagrant/venvs/cv/bin/pip2 install -r ../files/pip-requirements.txt",
    "failed": true,
    "invocation": {
        "module_args": {
            "chdir": null,
            "editable": true,
            "executable": null,
            "extra_args": null,
            "name": null,
            "requirements": "../files/pip-requirements.txt",
            "state": "present",
            "umask": null,
            "use_mirrors": true,
            "version": null,
            "virtualenv": "/home/vagrant/venvs/cv",
            "virtualenv_command": "virtualenv",
            "virtualenv_python": "python2.7",
            "virtualenv_site_packages": false
        },
        "module_name": "pip"
    },
    "msg": "\n:stderr: Could not open requirements file: [Errno 2] No such file or directory: '../files/pip-requirements.txt'\n"
}

1 个答案:

答案 0 :(得分:2)

pip模块期望pip-requirements.txt文件位于目标框中:

  

pip要求文件的路径,该文件应该是远程系统的本地文件。如果使用chdir选项,则可以将文件指定为相对路径。

因此,如果您的配置流程没有将您的本地文件夹复制/链接到流浪盒中,则没有NSCoding可用。