-
Notifications
You must be signed in to change notification settings - Fork 31
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
Implement a test infrastructure. For #6 #7
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tomorrow I'll rebase this on master to solve conflicts |
Merge latest changes from upstream
…into feat/test-kitchen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently generated roles do not include any test facility.
I am providing a pull request that implements testing with Ansible-lint, yamllint, Test-Kitchen configured with the kitchen-docker driver and kitchen-inspec.
See #6
Idea behind this pull request
While developing roles, I always wanted to test them in an ephemeral environment.
In my first role, I just ran a quick syntax check using the
--syntax-check
switch. Then I came across this blog post from Jeff Geerling and I was able to use his approach to use Travis to run my role against different platforms (using Docker), while also testing the idempotence.But this methodology had a limitation: running tests on my local Docker environment was cumbersome and not practical as the process had too many copy-and-paste-from-.travis.yml steps. I managed to mitigate this issue to a certain extent by moving commands from
.travis.yml
to dedicated shell scripts (that you can now find in thetest/scripts
directory).This partially solved the issue but the
.travis.yml
still contained the environment variables that described the platforms to run against (i.e. the Docker containers). So I still had some manual steps.Then I stumbled upon Test-Kitchen. It's a testing framework with a nice plugin interface. You can use it with various combinations of drivers (Docker, Vagrant...), provisioners (Ansible, Chef...) and verifiers (RSpec, Serverspec, InSpec...). This completely abstracts the test environment from the "test runtime" environment, in the sense that you can run the same set of tests against different platforms, no matter the environment you use to run such tests. But wait, couldn't you just use plain docker for that? Yes, but you may encounter the two issues I described above.
What this pull request does?
It adds support to run tests with Test Kitchen. Each platform (configured in the
.kitchen.yml
) to run test against is managed with Docker (via thekitchen-docker
driver). The provisioner (configured in the.kitchen.yml
) is Ansible obviously. Lastly I configured a verifier and chose InSpec, an open source testing framework for infrastructure that can be used to write assertions about your instances, made by the Chef guys.It also configures checks with yamllint and Ansible-lint.
Examples