2016-12-27 86 views
0

ansible/ansible-剧本版本:2.1.2.0Ansible PIP模块:名称包和的umask 0022致命错误:无效字面对于int()与基座8: '18' 的umask必须是一个八进制整数

我有在我的剧本了以下行动:

- name: Install cli (as well) 
    pip: 
    name: "{{ mycompany_pip_pkg }}" 
    umask: 0022 

为什么会收到以下致命错误消息,即使我遵循Ansible pip模块文档: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 

UPDATE:
问题:
1)为什么在Ansible pip模块,当name属性的值包含无效的包名,那么这个模块失败的umask属性的值(这是正确的,我案件)?

+0

好吧,我找到了解决方案,但仍然,为什么第一节的语法不工作! –

回答

1

尽管自由格式(YAML样式)参数仍被接受但不推荐,但Ansible仍希望格式为key=value格式的模块的参数。

Conventions/Recommendations

Modules can also take free-form arguments instead of key-value or json but this is not recommended.

+0

我同意。想知道为什么他们会在他们的文档中提到相同的内容,请看他们的最后一个例子如果我使用自由形式的YAML语法而不使用'umask:0022或umask:... property',它就可以工作。我在其他剧本中为其他模块使用了自由形式的YAML语法,它们都可以工作。我认为'pip.py'需要修正'umask'属性。我看到使用自由格式YAML的优点是更好的缩进/用户阅读友好语法-vs-将所有属性/变量放在一行中。 –

+0

我提供了一个更新到我的帖子,现在我的帖子是问一个有效的问题:)(我做了一些调查后发现)希望你能提供一些光。 –

+0

我不认为“自由形式”这个词在这里适用于YAML风格。你有什么参考?包括明确声明YAML风格不推荐?我认为自由风格指的是,例如'local_action'模块,您可以在其中指定模块作为键​​值或直接在'local_action'的值中指定模块。 – techraf

0

中包装的umask引号为我工作。 PIP: 名称:uwsgi 状态:目前 的umask: '0022'

# ls -lah /bin/uwsgi -rwxr-xr-x. 1 root root 1.3M Jan 21 12:12 /bin/uwsgi 
+0

是的,我也是这样做的:'pip:name =“{{pip_pkg}}”umask =“0022”'但是在同一行上,不是自由形式的yaml form –

1

只需用引号括起来的umask值。

不起作用:

pip: 
    name: 
     - pika 
     - argparse 
    umask: 0022 

是否工作:

pip: 
    name: 
     - pika 
     - argparse 
    umask: "0022" 

使用,直到它得到了固定https://github.com/ansible/ansible/issues/9196以 “文件” 模块出现同样的问题。正如其他人指出的,使用key = value语法也适用。

相关问题