Ansible failing on Amazon Linux AMI 2015.03

532 views
Skip to first unread message

Co S

unread,
Aug 10, 2015, 12:31:20 PM8/10/15
to Ansible Project
Hi All,

Just launched an instance with Amazon Linux 2015.03 image, added epel-release repository and run "yum install ansible". All went fine so far.
Now when I try to run "ansible" or "ansible-playbook" from command line I get this error:
Error:
Traceback (most recent call last):
 
File "./ansible", line 26, in <module>
   
import ansible.runner
ImportError: No module named ansible.runner

I found that yum installs ansible libraries under /usr/lib64/python2.6/site-packages/ while the default python version in system (reported through "python --version") is Python 2.7.9 so it seems to be expected under /usr/lib64/python2.7/site-packages/ ... but it's not there.

$ alternatives --display python
python
- status is auto.
 link currently points to
/usr/bin/python2.7
/usr/bin/python2.7 - priority 27000
 slave asadmin
: /usr/bin/asadmin-2.7
 slave bundle_image
: /usr/bin/bundle_image-2.7
 slave cfadmin
: /usr/bin/cfadmin-2.7
 slave cq
: /usr/bin/cq-2.7
 slave cwutil
: /usr/bin/cwutil-2.7
 slave dynamodb_dump
: /usr/bin/dynamodb_dump-2.7
 slave dynamodb_load
: /usr/bin/dynamodb_load-2.7
 slave easy_install
: /usr/bin/easy_install-2.7
 slave elbadmin
: /usr/bin/elbadmin-2.7
 slave fetch_file
: /usr/bin/fetch_file-2.7
 slave glacier
: /usr/bin/glacier-2.7
 slave instance_events
: /usr/bin/instance_events-2.7
 slave jp
: /usr/bin/jp.py-2.7
 slave jp
.py: /usr/bin/jp.py-2.7
 slave kill_instance
: /usr/bin/kill_instance-2.7
 slave launch_instance
: /usr/bin/launch_instance-2.7
 slave list_instances
: /usr/bin/list_instances-2.7
 slave lss3
: /usr/bin/lss3-2.7
 slave mturk
: /usr/bin/mturk-2.7
 slave pip
: /usr/bin/pip-2.7
 slave pyami_sendmail
: /usr/bin/pyami_sendmail-2.7
 slave pybabel
: /usr/bin/pybabel-2.7
 slave pydoc
: /usr/bin/pydoc2.7
 slave pystache
: /usr/bin/pystache-2.7
 slave pystache
-test: /usr/bin/pystache-test-2.7
 slave python
-config: /usr/bin/python2.7-config
 slave route53
: /usr/bin/route53-2.7
 slave rst2html
: /usr/bin/rst2html-2.7
 slave rst2latex
: /usr/bin/rst2latex-2.7
 slave rst2man
: /usr/bin/rst2man-2.7
 slave rst2odt
: /usr/bin/rst2odt-2.7
 slave rst2odt_prepstyles
: /usr/bin/rst2odt_prepstyles-2.7
 slave rst2pseudoxml
: /usr/bin/rst2pseudoxml-2.7
 slave rst2s5
: /usr/bin/rst2s5-2.7
 slave rst2xetex
: /usr/bin/rst2xetex-2.7
 slave rst2xml
: /usr/bin/rst2xml-2.7
 slave rstpep2html
: /usr/bin/rstpep2html-2.7
 slave s3put
: /usr/bin/s3put-2.7
 slave sdbadmin
: /usr/bin/sdbadmin-2.7
 slave taskadmin
: /usr/bin/taskadmin-2.7
 slave urlgrabber
: /usr/bin/urlgrabber-2.7
 slave virtualenv
: /usr/bin/virtualenv-2.7
 slave python
.1.gz: /usr/share/man/man1/python2.7.1.gz
/usr/bin/python2.6 - priority 2600
 slave asadmin
: (null)
 slave bundle_image
: (null)
 slave cfadmin
: (null)
 slave cq
: (null)
 slave cwutil
: (null)
 slave dynamodb_dump
: (null)
 slave dynamodb_load
: (null)
 slave easy_install
: /usr/bin/easy_install-2.6
 slave elbadmin
: (null)
 slave fetch_file
: (null)
 slave glacier
: (null)
 slave instance_events
: (null)
 slave jp
: (null)
 slave jp
.py: (null)
 slave kill_instance
: (null)
 slave launch_instance
: (null)
 slave list_instances
: (null)
 slave lss3
: (null)
 slave mturk
: (null)
 slave pip
: (null)
 slave pyami_sendmail
: (null)
 slave pybabel
: /usr/bin/pybabel-2.6
 slave pydoc
: /usr/bin/pydoc2.6
 slave pystache
: (null)
 slave pystache
-test: (null)
 slave python
-config: (null)
 slave route53
: (null)
 slave rst2html
: (null)
 slave rst2latex
: (null)
 slave rst2man
: (null)
 slave rst2odt
: (null)
 slave rst2odt_prepstyles
: (null)
 slave rst2pseudoxml
: (null)
 slave rst2s5
: (null)
 slave rst2xetex
: (null)
 slave rst2xml
: (null)
 slave rstpep2html
: (null)
 slave s3put
: (null)
 slave sdbadmin
: (null)
 slave taskadmin
: (null)
 slave urlgrabber
: (null)
 slave virtualenv
: (null)
 slave python
.1.gz: /usr/share/man/man1/python2.6.1.gz
Current `best' version is /usr/bin/python2.7.


Is this expected behaviour? Why it installs under old version of python?

Thanks in advance,
Constantin

 

Mark Phillips

unread,
Aug 10, 2015, 12:56:04 PM8/10/15
to Ansible Project
Amazon Linux already has EPEL configured, so you should just be able to do 'yum install ansible'.

It looks like you've put the EPEL repo in place for RHEL6, when Amazon Linux is closer to 7 - hence the Python 2.7 dependency.
...

Co S

unread,
Aug 11, 2015, 4:31:04 AM8/11/15
to Ansible Project
Thanks Mark. In fact it doesn't come with "epel-release" package installed by default (amzn-ami-hvm-2015.03.0.x86_64-gp2 (ami-a10897d6)):

$ yum repolist all
Loaded plugins: priorities, update-motd, upgrade-helper
amzn
-main/latest                                                                                               | 2.1 kB     00:00
amzn
-main/latest/group                                                                                         |  35 kB     00:00
amzn
-main/latest/primary_db                                                                                    | 3.3 MB     00:00
amzn
-updates/latest                                                                                            | 2.3 kB     00:00
amzn
-updates/latest/group                                                                                      |  35 kB     00:00
amzn
-updates/latest/updateinfo                                                                                 | 249 kB     00:00
amzn
-updates/latest/primary_db                                                                                 | 879 kB     00:00
repo id                                                        repo name                                                status
amzn
-main/latest                                               amzn-main-Base                                           enabled: 5,302
amzn
-main-debuginfo/latest                                     amzn-main-debuginfo                                      disabled
amzn
-nosrc/latest                                              amzn-nosrc-Base                                          disabled
amzn
-preview/latest                                            amzn-preview-Base                                        disabled
amzn
-preview-debuginfo/latest                                  amzn-preview-debuginfo                                   disabled
amzn
-updates/latest                                            amzn-updates-Base                                        enabled: 1,298
amzn
-updates-debuginfo/latest                                  amzn-updates-debuginfo                                   disabled
repolist
: 6,600

Yes, I run "yum install epel-release" and then "yum install ansible --enablerepo=epel" and I get this:
# yum install ansible --enablerepo=epel
Loaded plugins: priorities, update-motd, upgrade-helper
980 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:1.9.2-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: ansible-1.9.2-1.el6.noarch
--> Processing Dependency: python-setuptools for package: ansible-1.9.2-1.el6.noarch
--> Processing Dependency: python-paramiko for package: ansible-1.9.2-1.el6.noarch
--> Processing Dependency: python-keyczar for package: ansible-1.9.2-1.el6.noarch
--> Processing Dependency: python-jinja2 for package: ansible-1.9.2-1.el6.noarch
--> Processing Dependency: python-httplib2 for package: ansible-1.9.2-1.el6.noarch
--> Processing Dependency: python-crypto2.6 for package: ansible-1.9.2-1.el6.noarch
--> Processing Dependency: PyYAML for package: ansible-1.9.2-1.el6.noarch
--> Running transaction check
---> Package python-crypto2.6.x86_64 0:2.6.1-2.el6 will be installed
---> Package python-keyczar.noarch 0:0.71c-1.el6 will be installed
--> Processing Dependency: python-pyasn1 for package: python-keyczar-0.71c-1.el6.noarch
--> Processing Dependency: python-crypto for package: python-keyczar-0.71c-1.el6.noarch
---> Package python26-PyYAML.x86_64 0:3.10-3.10.amzn1 will be installed
---> Package python26-httplib2.noarch 0:0.7.7-1.5.amzn1 will be installed
---> Package python26-jinja2.noarch 0:2.7.2-2.15.amzn1 will be installed
--> Processing Dependency: python26-markupsafe for package: python26-jinja2-2.7.2-2.15.amzn1.noarch
--> Processing Dependency: python26-babel for package: python26-jinja2-2.7.2-2.15.amzn1.noarch
---> Package python26-paramiko.noarch 0:1.15.1-1.5.amzn1 will be installed
--> Processing Dependency: python26-ecdsa for package: python26-paramiko-1.15.1-1.5.amzn1.noarch
---> Package python26-setuptools.noarch 0:12.2-1.30.amzn1 will be installed
--> Processing Dependency: python26-backports-ssl_match_hostname for package: python26-setuptools-12.2-1.30.amzn1.noarch
---> Package python26-simplejson.x86_64 0:3.6.5-1.12.amzn1 will be installed
--> Running transaction check
---> Package python26-babel.noarch 0:0.9.4-5.1.8.amzn1 will be installed
---> Package python26-backports-ssl_match_hostname.noarch 0:3.4.0.2-1.12.amzn1 will be installed
--> Processing Dependency: python26-backports for package: python26-backports-ssl_match_hostname-3.4.0.2-1.12.amzn1.noarch
---> Package python26-crypto.x86_64 0:2.6.1-1.10.amzn1 will be installed
---> Package python26-ecdsa.noarch 0:0.11-3.3.amzn1 will be installed
--> Processing Dependency: python26-six for package: python26-ecdsa-0.11-3.3.amzn1.noarch
---> Package python26-markupsafe.x86_64 0:0.11-4.6.amzn1 will be installed
---> Package python26-pyasn1.noarch 0:0.1.7-2.7.amzn1 will be installed
--> Running transaction check
---> Package python26-backports.x86_64 0:1.0-3.14.amzn1 will be installed
---> Package python26-six.noarch 0:1.8.0-1.23.amzn1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================
 Package                                           Arch               Version                          Repository                Size
======================================================================================================================================
Installing:
 ansible                                           noarch             1.9.2-1.el6                      epel                     1.7 M
Installing for dependencies:
 python-crypto2.6                                  x86_64             2.6.1-2.el6                      epel                     513 k
 python-keyczar                                    noarch             0.71c-1.el6                      epel                     219 k
 python26-PyYAML                                   x86_64             3.10-3.10.amzn1                  amzn-main                186 k
 python26-babel                                    noarch             0.9.4-5.1.8.amzn1                amzn-main                1.8 M
 python26-backports                                x86_64             1.0-3.14.amzn1                   amzn-main                5.2 k
 python26-backports-ssl_match_hostname             noarch             3.4.0.2-1.12.amzn1               amzn-main                 12 k
 python26-crypto                                   x86_64             2.6.1-1.10.amzn1                 amzn-main                697 k
 python26-ecdsa                                    noarch             0.11-3.3.amzn1                   amzn-main                 77 k
 python26-httplib2                                 noarch             0.7.7-1.5.amzn1                  amzn-main                 81 k
 python26-jinja2                                   noarch             2.7.2-2.15.amzn1                 amzn-main                899 k
 python26-markupsafe                               x86_64             0.11-4.6.amzn1                   amzn-main                 27 k
 python26-paramiko                                 noarch             1.15.1-1.5.amzn1                 amzn-main                1.3 M
 python26-pyasn1                                   noarch             0.1.7-2.7.amzn1                  amzn-main                174 k
 python26-setuptools                               noarch             12.2-1.30.amzn1                  amzn-updates             582 k
 python26-simplejson                               x86_64             3.6.5-1.12.amzn1                 amzn-main                210 k
 python26-six                                      noarch             1.8.0-1.23.amzn1                 amzn-main                 31 k
Transaction Summary
======================================================================================================================================
Install  1 Package (+16 Dependent packages)
Total download size: 8.5 M
Installed size: 30 M
Is this ok [y/d/N]: y
Downloading packages:
(1/17): ansible-1.9.2-1.el6.noarch.rpm                                                                         | 1.7 MB     00:00
(2/17): python-crypto2.6-2.6.1-2.el6.x86_64.rpm                                                                | 513 kB     00:00
(3/17): python-keyczar-0.71c-1.el6.noarch.rpm                                                                  | 219 kB     00:00
(4/17): python26-PyYAML-3.10-3.10.amzn1.x86_64.rpm                                                             | 186 kB     00:00
(5/17): python26-babel-0.9.4-5.1.8.amzn1.noarch.rpm                                                            | 1.8 MB     00:00
(6/17): python26-backports-1.0-3.14.amzn1.x86_64.rpm                                                           | 5.2 kB     00:00
(7/17): python26-backports-ssl_match_hostname-3.4.0.2-1.12.amzn1.noarch.rpm                                    |  12 kB     00:00
(8/17): python26-crypto-2.6.1-1.10.amzn1.x86_64.rpm                                                            | 697 kB     00:00
(9/17): python26-ecdsa-0.11-3.3.amzn1.noarch.rpm                                                               |  77 kB     00:00
(10/17): python26-httplib2-0.7.7-1.5.amzn1.noarch.rpm                                                          |  81 kB     00:00
(11/17): python26-jinja2-2.7.2-2.15.amzn1.noarch.rpm                                                           | 899 kB     00:00
(12/17): python26-markupsafe-0.11-4.6.amzn1.x86_64.rpm                                                         |  27 kB     00:00
(13/17): python26-paramiko-1.15.1-1.5.amzn1.noarch.rpm                                                         | 1.3 MB     00:00
(14/17): python26-pyasn1-0.1.7-2.7.amzn1.noarch.rpm                                                            | 174 kB     00:00
(15/17): python26-setuptools-12.2-1.30.amzn1.noarch.rpm                                                        | 582 kB     00:00
(16/17): python26-simplejson-3.6.5-1.12.amzn1.x86_64.rpm                                                       | 210 kB     00:00
(17/17): python26-six-1.8.0-1.23.amzn1.noarch.rpm                                                              |  31 kB     00:00
--------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                 9.8 MB/s | 8.5 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python26-crypto-2.6.1-1.10.amzn1.x86_64                                                                           1/17
  Installing : python26-markupsafe-0.11-4.6.amzn1.x86_64                                                                         2/17
  Installing : python26-pyasn1-0.1.7-2.7.amzn1.noarch                                                                            3/17
  Installing : python-keyczar-0.71c-1.el6.noarch                                                                                 4/17
  Installing : python26-backports-1.0-3.14.amzn1.x86_64                                                                          5/17
  Installing : python26-backports-ssl_match_hostname-3.4.0.2-1.12.amzn1.noarch                                                   6/17
  Installing : python26-setuptools-12.2-1.30.amzn1.noarch                                                                        7/17
  Installing : python26-babel-0.9.4-5.1.8.amzn1.noarch                                                                           8/17
  Installing : python26-jinja2-2.7.2-2.15.amzn1.noarch                                                                           9/17
  Installing : python-crypto2.6-2.6.1-2.el6.x86_64                                                                              10/17
  Installing : python26-httplib2-0.7.7-1.5.amzn1.noarch                                                                         11/17
  Installing : python26-six-1.8.0-1.23.amzn1.noarch                                                                             12/17
  Installing : python26-ecdsa-0.11-3.3.amzn1.noarch                                                                             13/17
  Installing : python26-paramiko-1.15.1-1.5.amzn1.noarch                                                                        14/17
  Installing : python26-PyYAML-3.10-3.10.amzn1.x86_64                                                                           15/17
  Installing : python26-simplejson-3.6.5-1.12.amzn1.x86_64                                                                      16/17
  Installing : ansible-1.9.2-1.el6.noarch                                                                                       17/17
  Verifying  : python26-setuptools-12.2-1.30.amzn1.noarch                                                                        1/17
  Verifying  : python26-jinja2-2.7.2-2.15.amzn1.noarch                                                                           2/17
  Verifying  : python26-paramiko-1.15.1-1.5.amzn1.noarch                                                                         3/17
  Verifying  : python-keyczar-0.71c-1.el6.noarch                                                                                 4/17
  Verifying  : python26-babel-0.9.4-5.1.8.amzn1.noarch                                                                           5/17
  Verifying  : python26-simplejson-3.6.5-1.12.amzn1.x86_64                                                                       6/17
  Verifying  : python26-PyYAML-3.10-3.10.amzn1.x86_64                                                                            7/17
  Verifying  : python26-backports-ssl_match_hostname-3.4.0.2-1.12.amzn1.noarch                                                   8/17
  Verifying  : python26-six-1.8.0-1.23.amzn1.noarch                                                                              9/17
  Verifying  : python26-crypto-2.6.1-1.10.amzn1.x86_64                                                                          10/17
  Verifying  : python26-ecdsa-0.11-3.3.amzn1.noarch                                                                             11/17
  Verifying  : ansible-1.9.2-1.el6.noarch                                                                                       12/17
  Verifying  : python26-httplib2-0.7.7-1.5.amzn1.noarch                                                                         13/17
  Verifying  : python-crypto2.6-2.6.1-2.el6.x86_64                                                                              14/17
  Verifying  : python26-backports-1.0-3.14.amzn1.x86_64                                                                         15/17
  Verifying  : python26-pyasn1-0.1.7-2.7.amzn1.noarch                                                                           16/17
  Verifying  : python26-markupsafe-0.11-4.6.amzn1.x86_64                                                                        17/17
Installed:
  ansible.noarch 0:1.9.2-1.el6
Dependency Installed:
  python-crypto2.6.x86_64 0:2.6.1-2.el6                   python-keyczar.noarch 0:0.71c-1.el6
  python26-PyYAML.x86_64 0:3.10-3.10.amzn1                python26-babel.noarch 0:0.9.4-5.1.8.amzn1
  python26-backports.x86_64 0:1.0-3.14.amzn1              python26-backports-ssl_match_hostname.noarch 0:3.4.0.2-1.12.amzn1
  python26-crypto.x86_64 0:2.6.1-1.10.amzn1               python26-ecdsa.noarch 0:0.11-3.3.amzn1
  python26-httplib2.noarch 0:0.7.7-1.5.amzn1              python26-jinja2.noarch 0:2.7.2-2.15.amzn1
  python26-markupsafe.x86_64 0:0.11-4.6.amzn1             python26-paramiko.noarch 0:1.15.1-1.5.amzn1
  python26-pyasn1.noarch 0:0.1.7-2.7.amzn1                python26-setuptools.noarch 0:12.2-1.30.amzn1
  python26-simplejson.x86_64 0:3.6.5-1.12.amzn1           python26-six.noarch 0:1.8.0-1.23.amzn1
Complete!
[root@ip-172-31-33-49 ~]# which ansible
/usr/bin/ansible
[root@ip-172-31-33-49 ~]# ansible

Traceback (most recent call last):
  File "/usr/bin/ansible", line 36, in <module>
    from ansible.runner import Runner

ImportError: No module named ansible.runner



It seems that it picks up the 2.6 version of python as dependency and not the 2.7.9.
Note: the Amazon Linux AMI 2015.03 comes by default pre-installed with both versions.
Any idea how to sort this out?

Regards,
Constantin.


Mark Phillips

unread,
Aug 11, 2015, 5:49:27 AM8/11/15
to Ansible Project
Because you don't need it Constantin. Amazon Linux already has EPEL plumbed in, it's just not enabled. See...

[ec2-user@ip-172-31-33-248 ~]$ yum --enablerepo=epel info ansible
Loaded plugins: priorities, update-motd, upgrade-helper
epel/x86_64/metalink                                                                   |  23 kB     00:00     
epel/x86_64                                                                            | 4.4 kB     00:00     
epel/x86_64/group_gz                                                                   | 149 kB     00:00     
epel/x86_64/updateinfo                                                                 | 1.0 MB     00:00     
epel/x86_64/primary_db                                                                 | 6.7 MB     00:00     
epel/x86_64/pkgtags                                                                    | 1.6 MB     00:00     
980 packages excluded due to repository priority protections
Available Packages
Name        : ansible
Arch        : noarch
Version     : 1.9.2
Release     : 1.el6
Size        : 1.7 M
Repo        : epel/x86_64
Summary     : SSH-based configuration management, deployment, and task execution system
URL         : http://ansible.com
Licence     : GPLv3

That was a freshly spun up instance with nothing else done to it.

HTH

--M

Co S

unread,
Aug 11, 2015, 6:23:13 AM8/11/15
to Ansible Project
You are right Mark. It's there.
Have you tried to run "ansible" form command line?
I still get the same error.

Mark Phillips

unread,
Aug 11, 2015, 1:33:01 PM8/11/15
to Ansible Project
Oh yes. I wonder if that's something that's broken lately?

Set python2.6 to be the default alternative and it works OK...

[ec2-user@ip-172-31-34-97 ~]$ sudo alternatives --set python /usr/bin/python2.6

[ec2-user@ip-172-31-34-97 ~]$ ansible --version
ansible 1.9.2

Co S

unread,
Sep 8, 2015, 4:59:05 AM9/8/15
to Ansible Project
Thanks Mark,

All worked fine.

Reply all
Reply to author
Forward
0 new messages