cosbug
August 10, 2015, 4:31pm
1
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
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
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.
cosbug
August 11, 2015, 8:31am
3
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
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
cosbug
August 11, 2015, 10:23am
5
You are right Mark. It’s there.
Have you tried to run “ansible” form command line?
I still get the same error.
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