Questions tagged [molecule]

Molecule is a Python package designed to aid in the development and testing of Ansible roles.

Molecule is a Python package designed to aid in the development and testing of Ansible roles. It includes support for multiple instances, operating system distributions, virtualization providers, and test frameworks.

It leverages Vagrant, Docker, and OpenStack to manage virtual machines/containers, with support for multiple Vagrant providers (currently VirtualBox, Parallels, VMware Fusion, and Libvirt). Molecule supports Serverspec, Testinfra, or Goss (beta) to run tests. Molecule uses an Ansible playbook (playbook.yml), to execute the role and its tests.

Find the source on Github and the documentation on the official website.

139 questions
3
votes
1 answer

GitHub Actions overrides provisioner user in molecule test

I have a project that utilizes Molecule for testing, and I've configured my molecule.yml file to use an unprivileged user (already created on the image pushed to a registry) named molecule during provisioning: provisioner: name: ansible …
staticdev
  • 2,950
  • 8
  • 42
  • 66
3
votes
1 answer

ansible molecule "python not found"

I have some ansible roles and I would like to use molecule testing with them. When I execute command molecule init scenario -r get_files_uid -d docker I get the following file structure get_files_uid ├── molecule │ └── default │ ├──…
a1dude
  • 174
  • 2
  • 13
3
votes
0 answers

Ansible Molecule how to use multiple group_vars

I have a folder structure like this in Ansible where global variables are at the root group_vars and then environment specific variables are in inventories/dev/group_vars/all etc. . ├── ansible.cfg ├── group_vars │   └── all ├── inventories │   ├──…
hitman222
  • 179
  • 4
  • 10
3
votes
1 answer

Ansible molecule using docker - how to specify memory limit

I have a molecule test which spins up 2 Docker containers, for testing 2 application versions at once. dependency: name: galaxy driver: name: docker lint: name: yamllint platforms: - name: molecule1 hostname: molecule1 image:…
Lester
  • 1,411
  • 1
  • 12
  • 30
3
votes
2 answers

Test dependant Ansible roles with molecule and gilt, zero documentation

Currently building multiple Ansible roles for my company some of which will be marked as dependant on one another(think like a deploy [application] containers role thats dependant on the role docker to be installed). We run our automated tests…
Sefiris
  • 31
  • 1
3
votes
1 answer

How to create Coulomb Matrix with Python?

I need some coulomb matrices of molecules for a machine learning task. Coulomb Matrix? Here's a paper describing it I found the Python package molml which has a method for it. However I can't figure out how to use the API for a single molecule only.…
maniac
  • 1,112
  • 1
  • 13
  • 19
2
votes
1 answer

molecule 5.0.0 docker driver fails

Since last week there is a new release of molecule 5.0.0. My CI/CD pipeline wants to use that latest version, but I've trouble with it. installation Earlier, it was possible to run pip install molecule[docker] to install all necessary libraries.…
TRW
  • 876
  • 7
  • 23
2
votes
1 answer

Ansible Molecule ignores collection requirements

I like to use a git based Ansible Collection with my role and try to test that role with molecule. But when I run molecule, there isno output showing me, it is adding that collection nor it find the module/filter during runtime. molecule 4.0.4 using…
TRW
  • 876
  • 7
  • 23
2
votes
0 answers

Use different Ansible collection versions in one Molecule scenario

I have an Ansible collection to install some software. Each software version is attached to a separate collection version. To test an upgrade I need to apply an old collection version first and then run the new version. To achieve that, I slightly…
Anatoli
  • 889
  • 2
  • 15
  • 33
2
votes
1 answer

Molecular decomposition using re

I would like to create a dictionary to split all elements of a molecular formula. I tried using re module Formula="C16H21NO2Na3" pat = re.compile('(?P[A-Z][a-z]+)\[0-9]+(?P[0-9]+)') molecule= pat.findall(Formula) print (molecule) I…
Van3
  • 49
  • 6
2
votes
1 answer

How do I share variables/facts between Molecule Playbooks?

I'm trying to share a variable between my converge step and my cleanup step of my Molecule. Since both playbooks are being run on the same host, I figure I can use facts to cache the variable as a fact. In converge.yml: - name: Cache some variable …
2
votes
1 answer

How to use molecule with Openstack

I use molecule a lot with the docker driver. There are a few cases where docker is not the right tool to test ansible roles against, so I'd like to spin up a vm in openstack. I've created an ansible role with molecule role -r and changed…
Timbo
  • 75
  • 8
2
votes
1 answer

override defaults/main.yml variables with molecule

I have the problem where my default values are normally stored in defaults/main.yml for running ansible scripts but I have not found a way to override them. I am using molecule to test, and I want a method of passing in variables into my…
Matthew Mccann
  • 164
  • 2
  • 9
2
votes
2 answers

`pip install docker-py` vs `pip install 'molecule[docker]'`?

I have seen people using pip install docker-py or pip install 'molecule[docker]'. I believe they are similar (equivalent?) I read https://molecule.readthedocs.io/en/stable/getting-started.html which says : Molecule requires an external Python…
k1eran
  • 4,492
  • 8
  • 50
  • 73
2
votes
1 answer

molecule tests for ansible roles - how to structure to avoid duplication

I have a lot of roles that I want to test via molecule, and I'm a molecule beginner. If I create a molecule scenario in each role, there will be significant duplicated code. Is there a pattern that people use to avoid have many roles with same…
k1eran
  • 4,492
  • 8
  • 50
  • 73
1
2
3
9 10