[PYTHON] How to run the Ansible module added in Ansible Tower

What is Ansible Tower?

A Red Hat product that allows you to run Ansible with a web GUI. In the operation part, Ansible Engin is also running, but it was a little different from going inside the server and running Ansible. It is not a standard module that can be used when Ansible is installed, but what should I do to move the additionally installed module? The environment is as follows.

About adding Ansible module

Official procedure for how to add a module with standard Ansible ) It will go smoothly. What I'm addicted to this time is that it works when I go inside the server and run Ansible, but it doesn't work from Tower. .. It seemed to be bald because other errors also occurred.

Pitfalls when using Python 3 to run playbooks in Ansible Tower

It has nothing to do with adding modules, but in the modules I added, the Python used must be 3 instead of 2, "ansible_python_interpreter" /reference_appendices/python_3_support.html) specified to use Python3 which was additionally installed in RHEL7. I was able to run it normally with python3 in normal Ansible, but when I run it with Tower, I get this error. .. ..

AttributeError: module 'enum' has no attribute 'IntFlag'

In conclusion, the following enum34 was bad in my environment, so I fixed it by balsing.

 /var/lib/awx/venv/ansible/bin/pip uninstall enum34

Added environment variables for modules added on Tower

Finally the main subject, but after fixing the enum bug above, the next is this error.

<module>ImportError: cannot import name 'ModuleName'

For the first time here, *** Oh, I thought that it could not be read ***, and as a result, there was a place to add an environment variable to the setting of Ansible Tower, ["ANSIBLE_LIBRARY" setting](https: // docs. By registering ansible.com/ansible/latest/dev_guide/developing_locally.html) as JSON, I was able to execute it normally.

{
 "ANSIBLE_LIBRARY": "/usr/share/ansible/plugins/modules/<added module name>",
 "ANSIBLE_MODULE_UTILS": "/usr/share/ansible/plugins/modules/<added module name>/module_utils/"
}

The location to set is Ansible Tower Settings> Jobs> Additional Environment Variables.

Recommended Posts

How to run the Ansible module added in Ansible Tower
How to use the optparse module
How to run TensorFlow 1.0 code in 2.0
How to use the ConfigParser module
How to use the C library in Python
How to run some script regularly in Django
How to run CNN in 1 system notation in Tensorflow 2
How to get the files in the [Python] folder
How to run Leap Motion in non-Apple Python
How to retrieve the nth largest value in Python
How to run AutoGluon in Google Colab GPU environment
How to get the number of digits in Python
How to know the current directory in Python in Blender
How to run python in virtual space (for MacOS)
How to use the Raspberry Pi relay module Python
How to run tests in bulk with Python unittest
How to use the exists clause in Django's queryset
How to run setUp only once in python unittest
How to resolve SSL module errors in Anaconda environment
How to use the model learned in Lobe in Python
How to access the global variable of the imported module
[Python] How to output the list values in order
How to use the generator
How to run Notepad ++ Python
How to develop in Python
How to use the decorator
How to increase the axis
How to start the program
How to write custom validations in the Django REST Framework
How to find the optimal number of clusters in k-means
[Ansible] How to call variables when creating your own module
[python] How to check if the Key exists in the dictionary
[TensorFlow 2 / Keras] How to run learning with CTC Loss in Keras
How to test the attributes added by add_request_method of pyramid
How to debug the Python standard library in Visual Studio
How to import NoteBook as a module in Jupyter (IPython)
How to use the __call__ method in a Python class
How to set the html class attribute in Django's forms.py
How to manipulate the DOM in an iframe with Selenium
How to log in automatically like 1Password from the CLI
(Note) How to pass the path of your own module
How to generate a query using the IN operator in Django
How to run the Export function of GCP Datastore automatically
How to get the last (last) value in a list in Python
How to get all the keys and values in the dictionary
In Django, how to abbreviate the long displayed string as ....
Notes on how to use marshmallow in the schema library
How to import NoteBook as a module in Jupyter (IPython)
[Shell] How to get the remote default branch in Git
Programming to fight in the world ~ 5-1
How to intentionally issue an error in the shell During testing
Programming to fight in the world 5-3
[Python] How to do PCA in Python
How to handle session in SQLAlchemy
How to use the zip function
How to handle multiple versions of CUDA in the same environment
[sh] How to store the command execution result in a variable
How to determine the existence of a selenium element in Python
How to install OpenCV on Cloud9 and run it in Python
How to implement Java code in the background of RedHat (LinuxONE)
How to resolve ModuleNotFoundError: No module named XXX in Jupyter Notebook