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
9
votes
1 answer

How to disable Molecule idempotence check on Ansible role test?

Using Molecule v.2 to test Ansible roles, I faced an issue with the check for a role to be idempotent. How can I disable this check? As documented, Molecule configuration parameters are required to be set in molecule.yml file, but I could not find…
Kiarash Zamanifar
  • 647
  • 1
  • 9
  • 19
8
votes
1 answer

Molecule - test roles from other directory

I want to test my roles which I have in other directory. Below my project structure: When I try use molecule, it can't find roles which are in roles directory. ❯ sudo molecule converge --> Test matrix └── default ├── dependency ├── create …
BElluu
  • 381
  • 5
  • 14
8
votes
2 answers

How to test ansible roles?

Scenario I want to develop ansible roles. Those roles should be validated through a CI/CD process with molecule and utilize docker as driver. This validation step should include multiple Linux flavours (e.g. centos/ubuntu/debian) times the supported…
ckaserer
  • 4,827
  • 3
  • 18
  • 33
7
votes
1 answer

Why Molecule is not able to start a docker container

I am using Molecule to test my ansible role. Before rebooting my server was working fine. However, after, When I run molecule create It is skipping the create process: Skipping, instances already created. However, nothing is running: (myenv)[root]#…
zegoat7
  • 457
  • 1
  • 6
  • 14
6
votes
1 answer

How to set no_log: true for molecule internal playbook tasks?

I am testing version compatibility with molecule and for the combination python 3.8 x ansible latest x debian molecule breaks in the instance creation step with TASK [Wait for instance(s) creation to complete] ******************************* FAILED…
ckaserer
  • 4,827
  • 3
  • 18
  • 33
6
votes
1 answer

How to test install and uninstall scenario with Molecule for Ansible?

In the Ansible role that I'm creating, I'm covering both an install and an uninstall scenario: foo-install.yml is called from main.yml when the install flag is set to true. foo-uninstall.yml is called from main.yml when the install flag is set to…
nwinkler
  • 52,665
  • 21
  • 154
  • 168
6
votes
2 answers

how to specify a vault password file to molecule test?

When running tests with molecule: molecule tests and some files are protected with ansible vault, the --vault-password-file must be specified to provide the password to decrypt their content. Although it is possible to do that with converge …
singuliere
  • 767
  • 10
  • 19
5
votes
1 answer

Molecule fails with "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"

I am using Ansible with Molecule. I just ran into the situation that converging my role failed with: fatal: [instance]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"} How to…
kghbln
  • 858
  • 2
  • 8
  • 18
5
votes
0 answers

Accessing Ansible variables in molecule test, TestInfra

I picked up molecule while researching around inspec and how to use it in ansible. I found molecule very cool and adopted it. I wanted to use it in 2 ways. 1- When developing a role or playbook 2- After a particular playbook have been run on…
black sensei
  • 6,528
  • 22
  • 109
  • 188
5
votes
1 answer

Molecule test has stopped working with my ansible role

I just started with molecule, followed a nice simple tutorial and I generated a role and did a molecule test and it worked as intended. I rebooted my machine the following day and it's stopped working again. ERROR: 'molecule/*/molecule.yml' glob…
black sensei
  • 6,528
  • 22
  • 109
  • 188
4
votes
2 answers

Why Molecule is not able to start a docker container (Failed to create temporary directory)

I found similar case here, that I am using molecule to test my ansible roles, but for some reason it is skipping "creation" part and gives error like: fatal: [rabbitmq]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary…
Eik
  • 41
  • 4
4
votes
3 answers

molecule error: computed fully qualified role name does not follow current galaxy requirements

I'am totally new to ansible and ansible roles. I have created my first role and want to test it with molecule. If I run molecule test I get an error saying: Computed fully qualified role name of generate_random_password does not follow current…
Tom Buyvoets
  • 51
  • 1
  • 3
4
votes
2 answers

Specify Collection dependency for Molecule

Molecule is informed to download role dependencies from Ansible Galaxy via dependency: name: galaxy options: role-file: requirements.yml However, there doesn't appear to be any documentation on how Molecule can be informed to download…
artis3n
  • 810
  • 2
  • 12
  • 23
4
votes
1 answer

Test failure of a playbook with Ansible Molecule

I'm creating a sudo role and want to test with Molecule that the role fails if a rule is not correct. How can we define that we expect the playbook to fail with Molecule? For example, if I have the following configuration: sudo__entries: - name:…
4
votes
2 answers

How do I skip some roles tasks when testing with Ansible Molecule?

What is the easiest way to skip some role tasks when I perform functional testing using Ansible Molecule?
sorin
  • 161,544
  • 178
  • 535
  • 806
1
2 3
9 10