ansible/ansible-playbook 版本:2.1.2.0
我的剧本中有以下操作:
- name: Install cli (as well)
pip:
name: "{{ mycompany_pip_pkg }}"
umask: 0022
为什么即使我遵循 Ansible pip
模块的文档,我还是收到以下 fatal error 消息:http://docs.ansible.com/ansible/pip_module.html
错误:
TASK [company.company-ansible : Install cli (as well)] ****************
fatal: [localhost]: FAILED! => {"changed": false, "details": "invalid literal for int() with base 8: '18'", "failed": true, "msg": "umask must be an octal integer"}
Ansible pip
文档说:
The system umask to apply before installing the pip package. This is useful, for example, when installing on systems that have a very restrictive umask by default (e.g., 0077) and you want to pip install packages which are to be used by all users. Note that this requires you to specify desired umask mode in octal, with a leading 0 (e.g., 0077).
http://programtalk.com/vs2/python/749/ansible-modules-core/packaging/language/pip.py/显示以下代码:
if umask and not isinstance(umask, int):
try:
umask = int(umask, 8)
except Exception:
module.fail_json(msg="umask must be an octal integer",
details=to_native(sys.exc_info()[1]))
PS:以下语法有效!但为什么上面的不起作用?
- name: Install cli (as well)
pip: name="{{ mycompany_pip_pkg }}" umask=0022
更新:
问题:
1) 为什么在 Ansible pip
模块中,当 name
属性的值包含无效的包名称时,该模块因 umask
属性的值而失败(其中在我的情况下是正确的)?
最佳答案
只需将 umask 值括在引号中即可。
不起作用:
pip:
name:
- pika
- argparse
umask: 0022
有效:
pip:
name:
- pika
- argparse
umask: "0022"
"file"模块曾经发生过同样的问题,直到用 https://github.com/ansible/ansible/issues/9196 修复它。 。正如其他人指出的那样,使用 key=value 语法也可以。
关于pip - Ansible pip 模块 : name package and umask 0022 Fatal error: invalid literal for int() with base 8: '18' umask must be an octal integer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41353011/