Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify lxml availability #2

Open
ckaserer opened this issue Jul 8, 2020 · 5 comments
Open

verify lxml availability #2

ckaserer opened this issue Jul 8, 2020 · 5 comments

Comments

@ckaserer
Copy link

ckaserer commented Jul 8, 2020

the maven_artefact module uses lxml without verifying if lxml is installed or not.
If lxml is not installed the playbook terminates with

The error was: ModuleNotFoundError: No module named 'lxml'

@ErhardSiegl
Copy link
Contributor

If lxml is not installed, it doesn't use it, however it still needs it ;-)
What is the expected behavior?

@ckaserer
Copy link
Author

ckaserer commented Jul 8, 2020

We could verify if lxml is installed.
If it not try to install it.
If that fails we terminate with an error message that lxml is required and that installation failed.

@ErhardSiegl
Copy link
Contributor

lxml is required only on the server side not on the target. So its installation should be part of the (one time) ansible installation on the server and not part of the Storc module. If a module should install prerequisites, then the maven_artefact module should install its prerequisites. maven_artefact however chooses to: If that fails we terminate with an error message that lxml is required.

However, the prerequisite lxml should be part of the documentation.

@ckaserer
Copy link
Author

ckaserer commented Jul 9, 2020

Ah, I believe I got it. The playbook delegates the execution of maven_artefact to the machine executing the playbook via delegate_to: 127.0.0.1. Hence the lxml is only a prerequisite for the system running the playbook and not the target system.

As such we could define it as a prerequisite in the documentation - I agree.

What would be the downside of adding functionality and robustness to the role via a self-healing action such as my proposed approach? e.g. viapip install lxml. Worst case it fails and we have to install it manually, best case the user doesn't even notice it.

@ErhardSiegl
Copy link
Contributor

There are the following downsides:

  1. It breaks the single-responsibility principle of the module. Storcs responsibility is to install a package on the target, not to mess around with the servers installation.
  2. It is unexpected and might (worst case) break some other stuff running on the server
  3. It adds code which has to be maintained
  4. I most likely will fail anyways because of missing permissions
  5. How you plan to install lxml might not be wanted by the administrator. See e.g. https://stackoverflow.com/questions/3811614/how-to-install-python-lxml-on-sles-11-64-bit

What you could do is to write a separate playbook called e.g. fix-prerequisites where you check (and fix missing) prerequisites. This would be run with root privileges and the administrator expects it to change the server installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants