AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'

Trying to install ansible using ansible-1.3.4-0.git201404030000.el6.noarch.rpm but it shows below error

[root@xyzabc0170 installables]# rpm -ivh ansible-1.3.4-0.git201404030000.el6.noarch.rpm
Preparing… ########################################### [100%]
1:ansible ########################################### [100%]
[root@xyzabc0170 installables]# ansible
Traceback (most recent call last):
File “/usr/bin/ansible”, line 24, in
from ansible.runner import Runner
File “/usr/lib/python2.6/site-packages/ansible/runner/init.py”, line 37, in
import ansible.inventory
File “/usr/lib/python2.6/site-packages/ansible/inventory/init.py”, line 27, in
from ansible.inventory.script import InventoryScript
File “/usr/lib/python2.6/site-packages/ansible/inventory/script.py”, line 25, in
from ansible import utils
File “/usr/lib/python2.6/site-packages/ansible/utils/init.py”, line 67, in
from keyczar.keys import AesKey
File “/usr/lib/python2.6/site-packages/keyczar/keys.py”, line 34, in
from Crypto.PublicKey import DSA
File “/usr/lib64/python2.6/site-packages/Crypto/PublicKey/DSA.py”, line 88, in
from Crypto.PublicKey import _DSA, _slowmath, pubkey
File “/usr/lib64/python2.6/site-packages/Crypto/PublicKey/_DSA.py”, line 30, in
from Crypto.PublicKey.pubkey import *
File “/usr/lib64/python2.6/site-packages/Crypto/PublicKey/pubkey.py”, line 30, in
from Crypto.Util.number import *
File “/usr/lib64/python2.6/site-packages/Crypto/Util/number.py”, line 56, in
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
AttributeError: ‘module’ object has no attribute ‘HAVE_DECL_MPZ_POWM_SEC’

Why? If you’re using a Fedora/RedHat based OS then you should probably use the version from EPEL. This is currently ansible-1.5.3-1.el6.noarch. 1.3.4 is rather an old release, so unless there is some bizarre reason for using that particular version then I would highly suggest using the latest release.

http://docs.ansible.com/intro_installation.html#latest-release-via-yum

Adam

Yep, this happens when your SSL libraries don’t match up with your python crypto libraries.

Ansible 1.3.4 is also very old and contains numerous things you don’t want to deploy.

Grab the latest.

This bit me enough times that i eventually added a task for it in my playbook for creating new ansible controllers.
Its NOT pretty. But it works and i’ve had no ill issues from it.

#https://github.com/ansible/ansible/issues/276

  • name: Patch bug related to pycrypto
    lineinfile: dest=/usr/lib64/python2.6/site-packages/Crypto/Util/number.py
    regexp=“{{item.regexp}}” line=“{{item.line}}”
    with_items:
  • { regexp: “HAVE_DECL_MPZ_POWM_SEC”, line: “#if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:” }
  • { regexp: “PowmInsecureWarning”, line: “# _warn(‘Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.’, PowmInsecureWarning)” }