Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[section_request] Testing Ansible playbooks and roles with Molecule + ansible-lint #101

Closed
robsonpeixoto opened this issue Jul 13, 2018 · 16 comments

Comments

@robsonpeixoto
Copy link

robsonpeixoto commented Jul 13, 2018

No description provided.

@geerlingguy
Copy link
Owner

geerlingguy commented Aug 9, 2018

Good question. The Molecule project has had a lot of uptake, and is definitely somewhat of a standard (even though I don't currently use it, ha!) for Ansible testing... I will consider it.

[2020 edit: now I use it everywhere, even for collections!]

@geerlingguy
Copy link
Owner

geerlingguy commented Sep 26, 2018

Yes. I will be working on it soon :)

I've been slowly moving some of my roles over to using Molecule instead of my home-grown solution, for example:

@geerlingguy
Copy link
Owner

geerlingguy commented Sep 28, 2018

Sheesh, and a few of my roles (like Jenkins, Kibana, and Kubernetes) have soaked up an entire evening. It's slow progress, but I've learned a good deal about Molecule, and how some of my earlier tests were not quite up to my own standards!

I think I'll make a more informal blog post first (hopefully published around AnsibleFest week, as I get bored of practicing my slides...), then convert that into a good, tested section in the book, hopefully before end of year!

@geerlingguy
Copy link
Owner

geerlingguy commented Oct 25, 2018

Here's the promised blog post: Testing your Ansible roles with Molecule

@geerlingguy
Copy link
Owner

geerlingguy commented Aug 20, 2019

And here's a blog post on using Molecule to test Ansible Collections. I promise, I'll get some of this content into the book soon :)

@wkhayrattee
Copy link

wkhayrattee commented Sep 23, 2019

Perfect @geerlingguy!
Look forward to updates. cheers

@geerlingguy geerlingguy changed the title [question] Are there plans to add a section of how to test using molecule? [section_request] Testing Ansible playbooks and roles with Molecule Jan 15, 2020
@geerlingguy
Copy link
Owner

geerlingguy commented Feb 4, 2020

And a good presentation on Molecule (the basics) from #cfgmgmt2020 https://cfp.cfgmgmtcamp.be/media/molecule_cfgmgmt2020.pdf

@geerlingguy
Copy link
Owner

geerlingguy commented Apr 1, 2020

People seem to keep requesting this quite frequently. I think I'll try to get the testing chapter rewritten post-haste!

@geerlingguy geerlingguy changed the title [section_request] Testing Ansible playbooks and roles with Molecule [section_request] Testing Ansible playbooks and roles with Molecule + ansible-lint Apr 21, 2020
@geerlingguy
Copy link
Owner

geerlingguy commented Apr 21, 2020

Working on this... note that I'm thinking of covering this (ansible-lint + molecule) in the 7th episode of Ansible 101.

@geerlingguy
Copy link
Owner

geerlingguy commented Apr 21, 2020

Also wanted to give a shout out to @loganmarchione for this reddit post mentioning How and why you should lint your Ansible playbooks.

@geerlingguy
Copy link
Owner

geerlingguy commented Apr 30, 2020

@geerlingguy
Copy link
Owner

geerlingguy commented May 6, 2020

While working on a full rewrite of the new chapter 12 tonight (I bumped 12/13/14 to 13/14/15 and extracted testing into its own chapter), I ran into an issue with ansible-lint: ansible-lint fails if not running in a directory that is a .git repo.

So for ansible-lint, I'll have an example that explicitly lists a playbook to lint, rather than relying on auto-discovery like I do with most of my roles.

@geerlingguy
Copy link
Owner

geerlingguy commented May 6, 2020

Also opened up an issue in the Molecule repo: Fix getting-started docs - Dockerfile no longer shipped by default. I can't resist!

@geerlingguy
Copy link
Owner

geerlingguy commented May 6, 2020

Very close to finishing up the majority of this chapter, but I had to finish up prep work for tomorrow's live stream (see #257)—anyone following this issue should check out the live video (https://www.youtube.com/watch?v=FaXVZ60o8L8) or watch it on demand later... I'll cover a little more depth in the book, but the video should be a good preview of what's coming in the next book version!

geerlingguy added a commit that referenced this issue May 10, 2020
Issue #101: Add molecule testing example.
@geerlingguy
Copy link
Owner

geerlingguy commented May 10, 2020

I have the example committed, and most of the chapter rewritten. I'll probably post a new version of the book next week. Moving the last portion of this work—using Molecule in a GitHub Actions workflow—into a separate issue.

@geerlingguy
Copy link
Owner

geerlingguy commented May 10, 2020

Split out the GitHub Actions for CI workflows into #264. Closing this issue.

For those interested, this topic is also being covered in my free / live / on-demand Ansible 101 series on YouTube:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants