pip - Ansible pip 模块 : name package and umask 0022 Fatal error: invalid literal for int() with base 8: '18' umask must be an octal integer

标签 pip ansible ansible-2.x octal

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/

相关文章:

python - pipenv 可以搜索像 "pip search"这样的包吗?

python-3.x - 无法使用 pip 安装 sent2trash

ansible - 如何为所有播放/主机设置 Ansible 变量?

linux - 通过ansible调用远程bash函数

json - 以正确的 JSON 格式将 ansible 任务的输出写入文件

python - PIP 安装无法找到 ffi.h,即使它识别 libffi

python - 如何在Linux下/usr/local/lib/python2.7/site-packages下安装Pip

Ansible - 在收集事实之前采取的行动

ansible - 基于变量执行角色

ansible if else 构造