Skip to content

Running as Python library fails if Ansible Galaxy requirements are not installed #24

@belal-i

Description

@belal-i

If you run Lampsible as a Python library, while the Ansible Galaxy requirements - currently community.general, community.mysql, community.crypto - are not all installed, Lampsible will fail because Ansible will throw an error due to the invalid task caused by the missing dependency.

In other words, if any of the three named dependencies are missing, the following code block will fail.

from lampsible.lampsible import Lampsible

l = Lampsible(
    web_user='some-user',
    web_host='some-host.com',
    action='wordpress',
    email_for_ssl='[email protected]',
    database_password='password',
    admin_password='password',
)
l.run()

It should be possible to enable the Lampsible class to handle missing dependencies. It could take some boolean attribute, like install_galaxy_dependencies, and if that's true, install any missing collections, and if it's false, and any collections are missing, raise an exception. However, it is currently not possible.

In the meantime, as a workaround, before you use Lampsible as a Python library, you must install the Ansible Galaxy requirements. The easiest way is to simply run Lampsible one time via CLI - something like lampsible [email protected] apache --insecure-no-ssl - and the program will offer to install the collections for you, which you can then accept. Alternatively, install them individually: ansible-galaxy collection install community.general community.mysql community.crypto

I will try to improve this soon, so that the Lampsible library will work out of the box, while still respecting the user's choice about what to install locally. However, the handling of Galaxy dependencies needs to be refactored altogether. For example, what if required collections are installed, but new versions are available? I want to look at the Ansible Galaxy code, to see if they have some functionality that can be leveraged to this end, or perhaps write some small helper library for this. I'm currently not sure if I can release a small fix for this, and then later refactor the Galaxy stuff, or to just refactor the Galaxy stuff in one shot, and include the fix for this issue with that, but I'm leaning toward the latter.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions