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

Testing ansible idempotency #116

Closed
bborysenko opened this issue Dec 21, 2015 · 4 comments
Closed

Testing ansible idempotency #116

bborysenko opened this issue Dec 21, 2015 · 4 comments

Comments

@bborysenko
Copy link
Contributor

Is there are some way to do it with kitchen-ansible ?

@metmajer
Copy link

Generally, there's no test for idempotency, unless you define a test scenario that allows you to test idempotent behavior of your module(s). As you probably know, a test case in kitchen-ansible is an ansible playbook that is located somewhere under test/integration. In such a test case you would call your role multiple times and then use serverspec (or any other of the supported test frameworks) to test whether the state has only been enforced once. If you think about an entry in a configuration file, you could test, whether the entry was created only once. Does that make sense?

@rndmh3ro
Copy link
Contributor

To follow up on @metmajer, here's the way I do it:

- name: wrapper playbook for kitchen testing "ansible-os-hardening" with custom vars for testing
  hosts: localhost
  roles:
    - ansible-os-hardening

- name: wrapper playbook for kitchen testing "ansible-os-hardening" with custom vars for testing
  hosts: localhost
  roles:
    - ansible-os-hardening

This essentially runs the role on the same host twice, so I can see if anything changed in the second run.

Though it would be nice to have an idempotency test like https://github.com/ahelal/kitchen-ansiblepush.

@bborysenko
Copy link
Contributor Author

@metmajer I suppose that serverspec or some other test framework is not well suitable for that kind, since it's require to make sure that we have idempotency test suite for each ansible task.

@rndmh3ro thanks for the link! Having something similar would be really great.

@neillturner
Copy link
Owner

thanks for PR in version 0.0.34

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

4 participants