Bug 32711

Summary: ansible-playbook: Unexpected Exception: 'module' object has no attribute '_vendor'
Product: Sisyphus Reporter: Ivan Zakharyaschev <imz>
Component: ansibleAssignee: Andrey Cherepanov <cas>
Status: CLOSED NOTABUG QA Contact: qa-sisyphus
Severity: major    
Priority: P3 CC: aen, cas, obirvalger
Version: unstable   
Hardware: all   
OS: Linux   
Bug Depends on: 32709    
Bug Blocks:    

Description Ivan Zakharyaschev 2016-11-03 21:37:36 MSK
When running ansinle-playbook, an exception always happens.

Surprizingly, if I try to evaluate the statement that causes the exception in an interpreter, no error happens:

$ python
Python 2.7.11 (default, Apr 15 2016, 13:09:43) 
[GCC 5.3.1 20151207 (ALT Linux 5.3.1-alt3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> sub = "playbook"
>>> myclass = "%sCLI" % sub.capitalize()
>>> myclass
'PlaybookCLI'
>>> getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
<class 'ansible.cli.playbook.PlaybookCLI'>
>>> 



$ rpm -qf "$(which ansible-playbook)"
ansible-2.0.2.0-alt2
$ ansible-playbook
ERROR! Unexpected Exception: 'module' object has no attribute '_vendor'
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 73, in <module>
    mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
  File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 30, in <module>
    from ansible.executor.playbook_executor import PlaybookExecutor
  File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 27, in <module>
    from ansible.executor.task_queue_manager import TaskQueueManager
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 28, in <module>
    from ansible.executor.play_iterator import PlayIterator
  File "/usr/lib/python2.7/site-packages/ansible/executor/play_iterator.py", line 29, in <module>
    from ansible.playbook.block import Block
  File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 25, in <module>
    from ansible.playbook.play import Play
  File "/usr/lib/python2.7/site-packages/ansible/playbook/play.py", line 27, in <module>
    from ansible.playbook.base import Base
  File "/usr/lib/python2.7/site-packages/ansible/playbook/base.py", line 35, in <module>
    from ansible.parsing.dataloader import DataLoader
  File "/usr/lib/python2.7/site-packages/ansible/parsing/dataloader.py", line 32, in <module>
    from ansible.parsing.vault import VaultLib
  File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 67, in <module>
    from cryptography.hazmat.primitives.hashes import SHA256 as c_SHA256
  File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/primitives/hashes.py", line 15, in <module>
    from cryptography.hazmat.backends.interfaces import HashBackend
  File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 90, in <module>
    packaging = pkg_resources._vendor.packaging
AttributeError: 'module' object has no attribute '_vendor'
$
Comment 1 Evgenii Terechkov 2016-11-03 22:05:32 MSK
Насколько я помню свои исследования, cli в 2.0* вполне официально нерабочий и обещался позже.
Comment 2 AEN 2016-11-03 23:40:17 MSK
(В ответ на комментарий №1)
> Насколько я помню свои исследования, cli в 2.0* вполне официально нерабочий и
> обещался позже.

Понятно, спасибо.
Нам дали потестировать облачное приложение, которое хочет cli в скрипте установки. Там скромно написано, что лучше запускать этот скрипт с ansible-2.2. :)
Comment 3 Ivan Zakharyaschev 2016-11-09 15:24:22 MSK
This error happens iff python-module-pycrypto is not installed.

The internal reasons for this have not been studied by me yet (perhaps, pycrypto is really needed, perhaps, pycrypto's absense leads to some alternative behavior which causes this error).

More investigation in future.

(If Python autoreqs are resurrected as in the build which I'm preparing in http://git.altlinux.org/tasks/171993/build/500/x86_64/ , pycrypto is detected, but as a dep of a module. But as we see, it must be also a dep of the main ansible code.)
Comment 4 Ivan Zakharyaschev 2016-11-09 21:38:08 MSK
More precise conditions for this error (in Sisyphus):

* ansible-playbook tries to use python-module-pycrypto

* if python-module-pycrypto is installed, it goes on successfully (without trying python-module-cryptography)

* if python-module-pycrypto is not installed, this fails, and ansible-playbook tries to use python-module-cryptography

* if python-module-cryptography is not installed, it goes on successfully

* if python-module-cryptography is installed, the above error occurs when using it
Comment 5 Ivan Zakharyaschev 2016-11-09 22:19:16 MSK
In p8, the same conditions for this error hold.

(The difference between the p8 and Sisyphus environments is that in p8 python-module-paramiko depends on python-module-pycrypto, which makes ansible-playbook happy because it depends on python-module-paramiko. And if one removes python-module-pycrypto, the same situation as in Sisyphus would be visible. In Sisyphus, python-module-paramiko depends on python-module-cryptography, so when it is used in ansible-playbook, this error happens.)