ansible/molecule

RFE: Collection aware and project-local ephemeral directories

Qalthos opened this issue · 2 comments

Presently, the ephemeral directory lives in XDG_CACHE_HOME:

/home/bthornto/.cache/molecule
└── extensions
    ├── default
    │   └── inventory

Following #4000, we could use the collection name when constructing the ephemeral directory. Today, if using molecule in multiple collections the ephemeral directory is shared due to the introduction of the "extensions" directory.

Additionally, it could be useful for the ephemeral directory to be local to the project, say in a .cache folder in the project root. This would aid debugging and help in containerized scenarios.

Could also be solved by #4266

For those wanting a workaround on this for the meantime, add this to your shell of choice:

molecule () {
    MOLECULE_EPHEMERAL_DIRECTORY=$(pwd)/molecule/state "$(/usr/bin/which molecule)" "$@"
}

It'll overwrite the molecule command and prefix it with a ephemeral dir that can be constructed programmatically