Python3, Boto3, and botocore AWS modules and "Module \"name\" shadows the name of a reserved keyword" error

I’m trying to install the boto3 and botocore modules in an area where Ansible can find them. I’m on a macbook pro with ansible installed using python3/pip3, not homebrew. Here’s the output of my “ansible --version” command:

ansible 2.8.2

config file = /Users/jill/Git/ansibled/ansible.cfg

configured module search path = [‘/Users/jill/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]

ansible python module location = /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible

executable location = /Library/Frameworks/Python.framework/Versions/3.7/bin/ansible

python version = 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) [Clang 6.0 (clang-600.0.57)]

However, when I try to run any of the AWS-specific Ansible modules, I’m running into errors that the boto3 and botocore could not be found. They are installed in:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages

I was getting the error:

FAILED! => {“changed”: false, “msg”: “Failed to import the required Python library (botocore or boto3) on MYMac-Python /usr/bin/python. Please read module documentation and install in the appropriate location”}

According to the documentation, that appropriate location is the ansible modules library in /usr/share/ansible/plugins/modules. If it’s installed somewhere else, then use the ANSIBLE_LIBRARY environment variable. The documentation says:

  • any directory added to the ANSIBLE_LIBRARY environment variable ($ANSIBLE_LIBRARY takes a colon-separated list like $PATH
    There are no examples for this environment variable in that page. Looking at the page on Environment variables, there are several ways to install an environment variable. I’ve tried several of them, but I need the variable within the role that I’m setting, not on the entire ansible playbook stack. Not everything in our environment is in AWS. Much of it is VMware and bare metal.

So, I have an override for localhost for building the AWS vpc stack in the cloud. That sets up vpc as a type of host but tells ansible not to use ssh to run commands on it. In that small file, I stuck the ansible_library override:

specify to run Ansible for hosts locally by default, not over SSH

ansible_connection: local

ansible_library: “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages:{{ ansible_library }}”

That worked to get the modules seen at last by the Mac implementation. There’s a more serious issue. I’m getting this error now:

FAILED! => {“reason”: “Module "name" shadows the name of a reserved keyword. Please rename or remove this module. Found at /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cryptography/x509/name.py”}

I haven’t found any leads promising in Google-fu to find the answer to this. Given that it’s in the crypto modules, it seems like that should not interfere with work done in Ansible itself, but it looks like it does.

My thoughts this morning before my last attempt on fixing ansible_library were to eliminate ansible on the Mac as an issue by running Docker with a Centos-based Ansible container. But this new error likely wouldn’t fix with the Docker/Ansible attempt. This is something with Ansible and Python3 and boto3/botocore.

My next thought is to just write up and codify my bash/python scripts that build this stuff and use the Ansible installation to fire off the scripts, eliminating all the nonsense with fighting with a tool that has not been built for purpose. After EC2 instances are built, I can manage those with Ansible afterward as if they are a local VM.

But here’s the real problem. Management wants to use Ansible to manage the AWS stuff. And half the stuff up there is serverless implementations that are really going to need Ansible working and not suffering errors like this crypto library error in the python3 implementation. I can continue to use Ansible as a task runner like Jenkins (build servers are basically glorified task runners), but then why not just build out the script stack and use Jenkins?

Has anyone seen this reserved keyword conflict in one of the Python libraries before and perhaps know a fix or what should be done to resolve it?