
Jeff Geerling (geerlingguy) explores Ansible Galaxy, ansible-lint, Molecule, and testing Ansible roles and playbooks based on content in the bestselling Ansible book, Ansible for DevOps.
There’s a role for that! https://www.ansible.com/theres-a-role-for-that
Making your playbooks maintainable: https://www.jeffgeerling.com/blog/2019/make-your-ansible-playbooks-flexible-maintainable-and-scalable-ansiblefest-austin-2018
Buy Ansible for DevOps:Ā https://www.ansiblefordevops.com
Sponsor Jeff on GitHub:Ā https://github.com/sponsors/geerlingguy
Support Jeff on Patreon:Ā https://www.patreon.com/geerlingguy
Contents:
00:00:00 – Start
00:00:20 – Intro
00:05:13 – Questions from last episode
00:10:35 – Ansible Galaxy requirements files
00:15:58 – Mac development playbook
00:17:17 – A new chapter for testing
00:19:15 – The Ansible testing spectrum
00:23:50 – Testing inline in playbooks
00:28:39 – Linting with yamllint
00:34:40 – Check syntax with –syntax-check
00:37:30 – Linting with ansible-lint
00:42:42 – Introduction to Molecule
00:47:23 – Testing a role with Molecule
00:55:52 – Role dev with molecule converge
00:59:15 – Using molecule login
01:00:54 – Other molecule commands
01:02:12 – Outtro
source
Thank you for the great series. I'm going through the book, and using these videos, as well.
In the "Testing a role with Molecule" part, seems that the `init` command should be different on newer Molecule versions, at least on 3.5.1. You need to specify a driver like `molecule init role myrole –driver-name docker`, otherwise Molecule will use "delegated" driver.
48:11 British people be like
I ran into an issue, when the docker container wasn't started, took me about a day to figure out, that it's easily solved by creating the role with 'molceule init role myrole -d docker'. I'm not smart… š
If I run `molecule init role rolename` and after that `molecule test` I get an error `Computed fully qualified role name of test does not follow current galaxy requirements`. I tried setting role_name in meta.yml. This didn't work
you're blessed. such an amazing and welcoming information. thanks!
A volleyball guy. #respect
is there a repo for your example?
Hi Jeff, Awesome content I just loved it. You should prepare online video courses for people. You can easily become a millionaire in a months time.
Just wanted to say thanks again for putting together this series. I have both the ebook and paper book – I still like a book I can write in.
I have been able to apply the examples against the Pi Cluster I started building. I feel like I'm years behind everyone, but your work is making it easier to catch up.
Viewing from Mexico, I want to do some Linux training labs fully automated with ansible and this seems like the perfect tool to make the labs fully multi distro. Hope to actually fulfill my idea š thanks for everything you put out there !
ROFL whilst following your segment about yamllint, this is 6 months after your vid, you might want to practice what you preach š
OK, the line too long warnings are mostly negligible, but the wrong indentation actually leads to code unintentionally being run in this case unless I am totally wrong, so it is probably an actual bug. When I indented that part to a full tab, it complained there was no end for that block, so who knows how ansible interoperates it.
./roles/geerlingguy.homebrew/.travis.yml
34:81 error line too long (81 > 80 characters) (line-length)
58:81 error line too long (85 > 80 characters) (line-length)
63:81 error line too long (104 > 80 characters) (line-length)
./roles/geerlingguy.homebrew/tasks/main.yml
8:81 error line too long (82 > 80 characters) (line-length)
16:81 error line too long (81 > 80 characters) (line-length)
88:3 error wrong indentation: expected 4 but found 2 (indentation)
115:81 error line too long (95 > 80 characters) (line-length)
./roles/geerlingguy.homebrew/tests/test.yml
12:10 error too many spaces inside braces (braces)
12:80 error too many spaces inside braces (braces)
12:81 error line too long (81 > 80 characters) (line-length)
Hello, where can i find documentation about vagrant driver (with virtualbox) ?
The newest i found is this:
https://molecule.readthedocs.io/en/2.17/configuration.html?highlight=vagrant#vagrant
It is for old version 2.17 and i don't see reference for all the options i can put into "platform" section.
Is it possible to reuse Vagrantfile so i don't have to rewrite it into molecule.yml ?
OH NO ITS RED SHIRT JEFF!!!!!
Thanks Jeff
TASK [Gathering Facts] *******************************************************
fatal: [instance]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "` echo ~/.ansible/tmp `"&& mkdir ~/.ansible/tmp/ansible-tmp-1604936469.4416668-21271-161981161453473 && echo ansible-tmp-1604936469.4416668-21271-161981161453473="` echo ~/.ansible/tmp/ansible-tmp-1604936469.4416668-21271-161981161453473 `" ), exited with result 1", "unreachable": true}
i get this error when i try to test :/
molecule 3.1.5
Error:
{'driver': [{'name': ['unallowed value docker']}]}
Does anyone know, what happens if you use an ansible-galaxy package and for some reason the owner deletes it from galaxy? would this stop it from being able to be downloaded and you lose that part of the playbook?
this is best explanation i have found so far. great work!
Very nice explanation, Thank you!
But How do I specify the collections path if I am using inside the role task? as it fails saying couldn't resolve module name with collection name…
Thanks Jeff your awesome your explains and content help me many times in my company
Just bought the book for full price. I'm using ansible for two years and from the beginning on I'm using your roles on galaxy. So thanks a lot for all your work.
At what layer in the testing spectrum would it be caught that a module dependency is missing? For example, the k8s module requires the python openshift package to be installed.
Excellent job Jeff, its very good for beginner . Thanks
Thank you very much…you help us greatly and someday i wish i could be like you.
Thanks a lot Jeff… nice video and very good step by step discussion on yamllint, ansible-lint and molecule… Thanks for this great series on Ansible.