As molecule is able to run a playbook with the role from the init action, can it be extended to run a playbook which in it's basic level just contains roles but may also contain tasks.
It would be great if we could be able to test playbooks as I have a bunch of custom roles that depend on my other roles hence can't be tested independently rather only in a playbook. 馃槂
molecule uses a playbook to test the role. If you have complicated setup requirements, you can get creative in this playbook. If you merely have dependency roles, then list them in the dependencies section of the meta/main.yml of the your running molecule against and all should be well.
If I have misunderstood your difficulty, please elaborate.
I know it runs a playbook, but in a situation where you have custom roles, roles from galaxy and tasks and your end goal is to provision a complete system it becomes complicated. For instance I have playbooks that will run 10+ roles and at the end I get a fully functioning system as part of my stack. Now the playbooks may contain roles that need to run before others do or that get their input from the outputs of other roles in which case dependency alone is not enough.
Right now this is my workflow;
test.py and testMolecule does a great job at automating the creation of a test machine (vagrant or docker), testing a role does what it should do (via testinfra or serverspec) and also idempotent test.
So now molecule does testing of roles how hard will it be to test a playbook which contains roles
The workflow will be something like this;
.molecule.yml etcplaybook.yml and 200+ lines of roles and tasksLet me know your thoughts. It just seems logical that if you can test roles you should be able to test playbooks regardless of how complex they are.
So you are asking if molecule could test a playbook, and that playbook may consist of numerous roles and tasks. You don't want to test a single role with a single playbook (you're already doing that), but more of a playbook that tests the integration of various components. Right?
Yes, precisely. Same thing it does now but on a grander level with playbooks.
You can do that today, allow molecule to know you are leveraging a requirements file, and it will automatically download your roles.
ansible:
requirements_file: requirements.yml
_or_
Simply tell molecule where the other roles are.
I usually use the latter approach. I have a directory with a bunch of roles in it, then I write "scenario" directories, which simply have a molecule.yml and playbook.yml that exercise all of my roles in conjunction. I then write tests to assert the outcome of the integration.
Cool... I'll give that a go!
@retr0h the mentioned link is outdated. Could you provide the new link? Sadly I could not find any other reference for this functionality than your post.
Most helpful comment
@retr0h the mentioned link is outdated. Could you provide the new link? Sadly I could not find any other reference for this functionality than your post.