Unable to upgrade to Ansible 2.2 on Mac

Hello,

I am trying to upgrade to Ansible 2.2 from 2.1 and below error is being thrown. Anyone come across this error ? if so can you please let me know how to get around this issue.

HW12662:playbooks sgowda$ ansible-playbook --version

ansible-playbook 2.1.0.0

config file = /Users/sgowda/Project/Readiness/git/HCube/clusterDeployment/ambari-setup/playbooks/ansible.cfg

configured module search path = Default w/o overrides

HW12662:playbooks sgowda$ pip install ansible --upgrade

Collecting ansible

Downloading ansible-2.2.0.0.tar.gz (2.4MB)

100% |████████████████████████████████| 2.4MB 438kB/s

Collecting paramiko (from ansible)

Downloading paramiko-2.1.1-py2.py3-none-any.whl (172kB)

100% |████████████████████████████████| 174kB 1.8MB/s

Requirement already up-to-date: jinja2 in /Library/Python/2.7/site-packages (from ansible)

Collecting PyYAML (from ansible)

Downloading PyYAML-3.12.tar.gz (253kB)

100% |████████████████████████████████| 256kB 1.4MB/s

Collecting setuptools (from ansible)

Downloading setuptools-32.2.0-py2.py3-none-any.whl (477kB)

100% |████████████████████████████████| 481kB 1.2MB/s

Requirement already up-to-date: pycrypto>=2.6 in /Library/Python/2.7/site-packages (from ansible)

Requirement already up-to-date: pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from paramiko->ansible)

Collecting cryptography>=1.1 (from paramiko->ansible)

Downloading cryptography-1.7.1-cp27-cp27m-macosx_10_10_intel.whl (2.4MB)

100% |████████████████████████████████| 2.4MB 425kB/s

Requirement already up-to-date: MarkupSafe in /Library/Python/2.7/site-packages (from jinja2->ansible)

Requirement already up-to-date: cffi>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko->ansible)

Collecting six>=1.4.1 (from cryptography>=1.1->paramiko->ansible)

Downloading six-1.10.0-py2.py3-none-any.whl

Collecting idna>=2.0 (from cryptography>=1.1->paramiko->ansible)

Downloading idna-2.2-py2.py3-none-any.whl (55kB)

100% |████████████████████████████████| 61kB 2.5MB/s

Collecting ipaddress (from cryptography>=1.1->paramiko->ansible)

Downloading ipaddress-1.0.17-py2-none-any.whl

Requirement already up-to-date: enum34 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko->ansible)

Requirement already up-to-date: pycparser in /Library/Python/2.7/site-packages (from cffi>=1.4.1->cryptography>=1.1->paramiko->ansible)

Installing collected packages: setuptools, six, idna, ipaddress, cryptography, paramiko, PyYAML, ansible

Found existing installation: setuptools 1.1.6

Uninstalling setuptools-1.1.6:

Exception:

Traceback (most recent call last):

File “/Library/Python/2.7/site-packages/pip/basecommand.py”, line 215, in main

status = self.run(options, args)

File “/Library/Python/2.7/site-packages/pip/commands/install.py”, line 342, in run

prefix=options.prefix_path,

File “/Library/Python/2.7/site-packages/pip/req/req_set.py”, line 778, in install

requirement.uninstall(auto_confirm=True)

File “/Library/Python/2.7/site-packages/pip/req/req_install.py”, line 754, in uninstall

paths_to_remove.remove(auto_confirm)

File “/Library/Python/2.7/site-packages/pip/req/req_uninstall.py”, line 115, in remove

renames(path, new_path)

File “/Library/Python/2.7/site-packages/pip/utils/init.py”, line 267, in renames

shutil.move(old, new)

File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 299, in move

copytree(src, real_dst, symlinks=True)

File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 208, in copytree

raise Error, errors

Error: [(‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py’, ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py’, “[Errno 1] Operation not permitted: ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py’”), (‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc’, ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc’, “[Errno 1] Operation not permitted: ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc’”), (‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py’, ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py’, “[Errno 1] Operation not permitted: ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py’”), (‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc’, ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc’, “[Errno 1] Operation not permitted: ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc’”), (‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib’, ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib’, “[Errno 1] Operation not permitted: ‘/var/folders/48/_kmsn1156xd44f616b2_k8w00000gp/T/pip-37HbNE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib’”)]

Looks like you dont have permission to write to some directories. Have you tried installing with sudo yet?

sudo pip install --upgrade ansible

-tim

Thank you for the reply Tim.

I get the same error even with sudo pip install --upgrade ansible.

I’ve had zero success trying to upgrade ansible on mac. I do ‘pip uninstall’ then a ‘pip install’ which gets the new one.

I have no Macs around for the moment to reproduce your issue, but one advice: don't try to upgrade libraries from the System Python.

One solution is to create a Virtualenv for Ansible and install all Ansible dependencies in it.

Another is to use a package manager like MacPorts or Homebrew.

HTH...

The problem is related to the new System Integrity Protection on Mac.

The installation is failing when trying to manipulate files located at /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/

System Integrity Protection, protects /System and disallows writes to that directory.

You must have installed something prior to the upgrade to El Capitan or newer that placed files where they can no longer be modified.

You can try to upgrade by using pip install --no-deps -U ansible which may or may not work.

Otherwise you will need to temporarily disable System Integrity Protection, remove the offending files, re-enable System Integrity Protection, and then upgrade ansible.

Regardless, without cleaning up those offending files, you will likely always have troubles.