Ansible-Test |Testing The Automation Code Becomes More Important | Inofgen Labs
Ciklum India
We develop Digital Solutions for Fortune 500 and fast-growing organisations alike around the world.
Introduction to ansible-test
As automation becomes increasingly important in more business cases, testing the automation code becomes more important. This is where ansible-test comes in: developers may use ansible-test to create testing processes that integrate with source code repositories to test their Ansible Content Collections for sanity, unit, and integration tests.
Collection developers can utilise ansible-test, a cli tool included with both ansible-core and ansible-base, to test their Collection and its content. From linting module documentation and code to performing unit and integration tests, the ansible-test can handle a wide range of testing activities.
How to run an ansible-test?
With Ansible-2.9's wide release of Ansible Content Collections, a user can now use ansible-test to test the collection itself. In order for ansible-test to execute tests on the Collection, it must be run from the collection root or below.
If you try to execute ansible-test outside of the aforementioned directory norms, you'll get the following error:
You can see how a collection root appears to ansible-test in the output above; it must be in the form of:
When you install a collection from Ansible Galaxy or Automation Hub, the default installation location is: {...}/ansible_collections/{namespace}/{collection}/ , which already satisfies the above directory convention.
Even if you specify the installation path to the ansible-galaxy cli (using the -p option), it will also install a collection inside the ansible_collections directory by creating one in the given path, like below:
How to test your collection using ansible test?
ansible-test allows you to conduct several types of tests on your Collections. These tests are classified as follows:
?Visit Us:?corp.infogen-labs.com?