How does Morpheus deal with Ansible collections and virtual environments?

Normally in Ansible Tower we can create a virtual environment and set ansible version to use or which python modules to use. How we can achieve the same with Morpheus?

Say for example we need to run a certain playbook with a combination of Ansible 2.13 and python 3.8, how can we achieve this? Because in Ansible now we need to install certain collections to run certain playbooks . How can we achieve this in Morpheus?

We’ve got a refactor in the works which should support different virtual environments. Collections can be installed via galaxy using a requirements.yml file in the root of the integration. That format is documented here. The collection will only be installed for that ansible task.

I’ve linked the Ansible Redesign below.

The virtual environments are designed for Ansible components or services which may use the different Ansible roles, in Morpheus perspective can we create virtual environments based on Workflows or Tasks . 5.5.1 version be default using python 3.6.8 and Ansible 2.10 both are deprecated versions.

We don’t currently have the capability to switch between different virtual environments using Morpheus Ansible Tasks. The best way to do it in Morpheus right now is to install an Ansible version at the system level that satisfies the requirements and dynamically install roles and collections from the integrations at runtime using a requirements.yml file.

Ok, Understood . In our requirement one component needs ansible 2.9 maybe another components needs 2.10 so it may varies. Previously we were using Tower as the trigger point , now we are planning to use morpheus that is one of the reason we raised this question. Anyway thanks for your update,

Are there any steps needed here beyond adding the requirements.yml file to the root of the integration repo and clicking the “use ansible galaxy” box? did both of those things and our collections are still not installing.

Not sure if it matters, but if it does, we are using an internal hub server, with /etc/ansible/ansible.cfg configured to point at it and with appropriate tokens

Those are the only steps that should be needed. Is there any output from a failed galaxy pull in the Morpheus logs?

nope, I see a bunch of “Ansible Galaxy Requirements File Detected…Running Galaxy” and then success messages but no errors. I am getting this git error semi-frequently though

[RxCachedThreadScheduler-17925] Duplicate entry 'morpheus-ui.git.754b5a1ad367c85d93f13a39d84dbfd2' for key NOTSUREIFTHISNEEDSREDACTED'

I have no immediate answer for that. There’s currently no debug for the galaxy output that I’m aware of. If you want to simulate what it would be doing, you could:

su - morpheus-local
mkdir <sometmp>
cd <sometmp>
<copy your requirements.yml there>
ANSIBLE_COLLECTIONS_PATH=<sometmp>/collections:~/.ansible/collections ansible-galaxy install -r requirements.yml

The thing to keep in mind is that we use the morpheus-local user for ansible runs, so if a collection already exists in ~/.ansible/collections for that user, then ansible-galaxy may skip it.

Either we think it’s already installed or it’s failing silently, those are the two possibilities I can think of at the moment.