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

Implement a test infrastructure. For #6 #7

Closed
wants to merge 30 commits into from

Conversation

ferrarimarco
Copy link
Contributor

@ferrarimarco ferrarimarco commented Jan 27, 2017

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 the test/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 the kitchen-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

@ferrarimarco
Copy link
Contributor Author

Tomorrow I'll rebase this on master to solve conflicts

@ferrarimarco
Copy link
Contributor Author

@iknite maybe it's bettere to close this PR and open a new one after discussing a bit in #7

@ferrarimarco ferrarimarco deleted the feat/test-kitchen branch October 12, 2017 11:00
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

Successfully merging this pull request may close these issues.

1 participant