tec*_*raf 7 python pip ansible
我正在使用Ansible的pip模块(Debian上的pip 7.1.2)从github安装Ansible:
- pip:
name: "git+https://github.com/ansible/ansible.git#egg=ansible"
state: latest
become: yes
Run Code Online (Sandbox Code Playgroud)
然后在随后的运行中我收到消息:
致命:[ansibletarget]:失败了!=> {"已更改":false,"cmd":"/ usr/local/bin/pip install -U -e git + https://github.com/ansible/ansible.git#egg=ansible","failed " :true,"msg":"stdout:从git获取ansible + https://github.com/ansible/ansible.git#egg=ansible \n正在更新./src/ansible clone \n命令git reset的完整输出 - hard -q origin/master:\n \n --------------------------------------- - \n \n:stderr:无法找到标记或分支'origin/master',假定提交.\nfatal:模糊参数'origin/master':未知修订版或路径不在工作树中.\n使用' - '将路径与修订分开,如下所示:\n'git [...] - [...]'\n命令\"git reset --hard -q origin/master \"失败,错误代码为128/TMP/SRC/ansible \n"个}
在/tmp/src我有一个ansible沿子目录pip-delete-this-directory.txt的文件.Pip不会删除它.
使用相同的行为(下载,未删除,后续调用时出错):
pip install -U -e git+https://github.com/ansible/ansible.git#egg=ansible
Run Code Online (Sandbox Code Playgroud)
基本上我希望我的剧本是幂等的.我可以在安装之前删除目标文件夹并解决问题,但是缺少什么,以便pip不删除内容,如其内容所示:
This file is placed here by pip to indicate the source was put
here by pip.
Once this package is successfully installed this source code will be
deleted (unless you remove this file).
Run Code Online (Sandbox Code Playgroud)
通过这种设置很难实现幂等行为。您可以通过编写签出存储库的代码来解决这个问题,如果存储库已经签出,只需执行 git pull origin master 和一些 pip 工作。问题是你真的想要这样吗?
有一个专门用于获取 Ansible 打包版本的发布存储库,它比尝试 pip 安装更适合这种情况。
Debian具体安装: