molecule-action icon indicating copy to clipboard operation
molecule-action copied to clipboard

Support `poetry run`

Open huyz opened this issue 1 year ago • 1 comments

I need to run molecule under the poetry environment, so that I can use the pytest-subtests package in my testinfra tests.

I'm not sure if there's a way to do this without forking this repo and hacking it. Basically, instead of molecule being executed, I need poetry run molecule to be executed.

Suggestions?

huyz avatar Feb 25 '23 17:02 huyz

I moved this project to poetry package manager but I didn't keep it in a docker container to minimize docker image size. I'm using docker multistage build and keeping only .venv folder in final image. You can try to install required modules as it described in Troubleshooting section

If you are trying to install any Python packages in order to run your Molecule tests such as the OpenStack SDK and getting errors such as this:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "openstacksdk is required for this module"}

You will need to do the following:

  1. Switch the dependency driver to shell inside Molecule, like this:

    dependency:
      name: shell
      command: "${MOLECULE_SCENARIO_DIRECTORY}/tools/install-dependencies"
    
  2. Once you have that, create a file in your scenario inside a tools folder and place whatever you need inside of it, such as:

    #!/bin/sh
    
    # Install OpenStack SDK
    pip install \
      --extra-index-url https://vexxhost.github.io/wheels/alpine-3.15/ \
      'openstacksdk<0.99.0'
    

gofrolist avatar Jan 15 '24 18:01 gofrolist