ansible-lint broken after upgrading ansible to ansible 2.7.6+dfsg-1
Closed, ResolvedPublic


ansible-lint is not working complaining about ansible module missing:

birin@librem13:~$ ansible-lint
Traceback (most recent call last):
  File "/usr/bin/ansible-lint", line 11, in <module>
    load_entry_point('ansible-lint==3.4.20', 'console_scripts', 'ansible-lint')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 487, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 2728, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 2346, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 2352, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/ansiblelint/", line 28, in <module>
    import ansiblelint.utils
  File "/usr/lib/python2.7/dist-packages/ansiblelint/", line 26, in <module>
    from ansible import constants
ImportError: No module named ansible

Looks like the new ansible 2.7.6+dfsg-1 is using python3 while ansible-lint uses python2. Therefore when 'ansible-lint' looks for ansible libraries under Python2 directories it does not find them:

birin@librem13:~$ apt-cache show ansible
Package: ansible
Version: 2.7.6+dfsg-1
Installed-Size: 33734
Maintainer: Harlan Lieberman-Berg <>
Architecture: all
Depends: python3-cryptography, python3-jinja2, python3-paramiko, python3-pkg-resources, python3-yaml, python3:any, python3-crypto, python3-httplib2, python3-netaddr
Recommends: python3-jmespath, python3-kerberos, python3-libcloud, python3-selinux, python3-winrm (>= 0.1.1), python3-xmltodict
Suggests: cowsay, sshpass
Description-en: Configuration management, deployment, and task execution system
 Ansible is a radically simple model-driven configuration management,
 multi-node deployment, and remote task execution system. Ansible works
 over SSH and does not require any software or daemons to be installed
 on remote nodes. Extension modules can be written in any language and
 are transferred to managed machines automatically.
Description-md5: db2b21b0d2286fccc4401d5982361488
Section: admin
Priority: optional
Filename: pool/main/a/ansible/ansible_2.7.6+dfsg-1_all.deb
Size: 3955540
SHA256: 2758ffe1587dbcf18b31934b8046709c51ec3b1e567449e137059c599fdd230d

birin@librem13:~$ apt-cache show ansible-lint
Package: ansible-lint
Version: 3.4.20+git.20180203-1
Installed-Size: 143
Maintainer: Gregory Colpart <>
Architecture: all
Depends: ansible, python-six, python-yaml, python:any (<< 2.8), python:any (>= 2.7.5-5~)
Description-en: lint tool for Ansible playbooks
 Ansible playbooks express configuration, deployment and orchestration in YAML
 format. They can describe a policy you want your remote systems to enforce,
  or a set of steps in a general IT process.
 ansible-lint checks Ansible playbooks for practices and behaviour that could
 potentially be improved.
Description-md5: a381932960794814b41d4276fb69f7a5
Section: misc
Priority: optional
Filename: pool/main/a/ansible-lint/ansible-lint_3.4.20+git.20180203-1_all.deb
Size: 24764
SHA256: 5acfdab3a258599da98df64b44f25ba6ec0fca2c4b7453ae86314392e6b13acb

A workaround is to use ansible-lint in a virtualenv:

birin@librem13:~$ virtualenv --python=python3 ansible_python3
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/birin/ansible_python3/bin/python3
Also creating executable in /home/birin/ansible_python3/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
birin@librem13:~$ source ansible_python3/bin/activate
(ansible_python3) birin@librem13:~$ pip install ansible-lint
Collecting ansible-lint
  Using cached
Collecting pyyaml (from ansible-lint)
Collecting ansible (from ansible-lint)
Collecting six (from ansible-lint)
  Using cached
Collecting ruamel.yaml (from ansible-lint)
  Using cached
Collecting cryptography (from ansible->ansible-lint)
  Using cached
Requirement already satisfied: setuptools in ./ansible_python3/lib/python3.7/site-packages (from ansible->ansible-lint) (40.8.0)
Collecting jinja2 (from ansible->ansible-lint)
  Using cached
Collecting paramiko (from ansible->ansible-lint)
  Using cached
Collecting cffi!=1.11.3,>=1.8 (from cryptography->ansible->ansible-lint)
  Using cached
Collecting asn1crypto>=0.21.0 (from cryptography->ansible->ansible-lint)
  Using cached
Collecting MarkupSafe>=0.23 (from jinja2->ansible->ansible-lint)
  Using cached
Collecting bcrypt>=3.1.3 (from paramiko->ansible->ansible-lint)
  Using cached
Collecting pynacl>=1.0.1 (from paramiko->ansible->ansible-lint)
  Using cached
Collecting pyasn1>=0.1.7 (from paramiko->ansible->ansible-lint)
  Using cached
Collecting pycparser (from cffi!=1.11.3,>=1.8->cryptography->ansible->ansible-lint)
Installing collected packages: pyyaml, six, pycparser, cffi, asn1crypto, cryptography, MarkupSafe, jinja2, bcrypt, pynacl, pyasn1, paramiko, ansible, ruamel.yaml, ansible-lint
Successfully installed MarkupSafe-1.1.0 ansible-2.7.7 ansible-lint-4.1.0 asn1crypto-0.24.0 bcrypt-3.1.6 cffi-1.11.5 cryptography-2.5 jinja2-2.10 paramiko-2.4.2 pyasn1-0.4.5 pycparser-2.19 pynacl-1.3.0 pyyaml-3.13 ruamel.yaml-0.15.87 six-1.12.0
(ansible_python3) birin@librem13:~$ ansible-lint 
Usage: ansible-lint [options] playbook.yml [playbook2 ...]

  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -L                    list all the rules
  -q                    quieter, although not silent output
  -p                    parseable output in the format of pep8
  --parseable-severity  parseable output including severity of rule
  -r RULESDIR           specify one or more rules directories using one or
                        more -r arguments. Any -r flags override the default
                        rules in
                        packages/ansiblelint/rules, unless -R is also used.
  -R                    Use default rules in
                        packages/ansiblelint/rules in addition to any extra
                        rules directories specified with -r. There is no need
                        to specify this if no -r flags are used
  -t TAGS               only check rules whose id/tags match these values
  -T                    list all the tags
  -v                    Increase verbosity level
  -x SKIP_LIST          only check rules whose id/tags do not match these
  --nocolor             disable colored output
  --force-color         Try force colored output (relying on ansible's code)
                        path to directories or files to skip. This option is
  -c C                  Specify configuration file to use.  Defaults to

Please notice that you can use Python2 or Python3 for your virtualenv... I just happened to choose Python3 for the ticket example.


This was reported in Debian recently:

Seems it was fixed today: (NEWS section in the middle)

That means it should enter PureOS soon, automagically...

birin.sanchez closed this task as "Resolved".Mar 19 2019, 3:21 PM
birin.sanchez claimed this task.

4.1.0+dfsg.1-1 is now in PureOS so the issue is gone.

Add Comment