ansible/ansible-playbook version: 2.1.2.0

I have the following action in my playbook:

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

Why am I getting the following fatal error message even though I followed the docs for Ansible pip module: http://docs.ansible.com/ansible/pip_module.html

Error:

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 Docs says:

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/ shows the following code:

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: The following syntax WORKS! but why the above one is not working?

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

UPDATE:
Question:
1) Why in Ansible pip module, when name property's value contains an invalid package name, then this module is failing for umask property's value (which is correct in my case)?

3

There are 3 answers

3
helloV On BEST ANSWER

Ansible expects arguments to modules in key=value format, even though the free-form (YAML style) arguments are still accepted but not recommended.

From Conventions/Recommendations

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

1
Bob On

Wrapping the umask in quotes worked for me. pip: name: uwsgi state: present umask: '0022'

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

Just enclose the umask value in quotes.

Doesn't work:

  pip:
    name:
      - pika
      - argparse
    umask: 0022

Does work:

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

The same problem used to occur with "file" module until it got fixed with https://github.com/ansible/ansible/issues/9196. As others pointed out, using key=value syntax works as well.