Blob Blame History Raw
diff --git a/tests/commonvars.yml b/tests/commonvars.yml
new file mode 100644
index 0000000..2cd3566
--- /dev/null
+++ b/tests/commonvars.yml
@@ -0,0 +1,2 @@
+restore_services:
+  - kdump
diff --git a/tests/get_services_state.yml b/tests/get_services_state.yml
new file mode 100644
index 0000000..4fe5d36
--- /dev/null
+++ b/tests/get_services_state.yml
@@ -0,0 +1,4 @@
+- name: Get initial state of services
+  tags: tests::cleanup
+  service_facts:
+  register: initial_state
diff --git a/tests/restore_services_state.yml b/tests/restore_services_state.yml
new file mode 100644
index 0000000..2035dfc
--- /dev/null
+++ b/tests/restore_services_state.yml
@@ -0,0 +1,22 @@
+- block:
+    - name: load common vars
+      include_vars:
+        file: commonvars.yml
+
+    - name: Get final state of services
+      service_facts:
+      register: final_state
+
+    - name: Restore state of services
+      service:
+        name: "{{ item }}"
+        state: "{{ 'started' if
+                   initial_state.ansible_facts.services[sname]['state']
+                   == 'running' else 'stopped' }}"
+      when:
+         - sname in final_state.ansible_facts.services
+         - sname in initial_state.ansible_facts.services
+      vars:
+        sname: "{{ item + '.service' }}"
+      with_items: "{{ restore_services }}"
+  tags: tests::cleanup
diff --git a/tests/tests_default.yml b/tests/tests_default.yml
index 4c93830..60d7967 100644
--- a/tests/tests_default.yml
+++ b/tests/tests_default.yml
@@ -1,6 +1,18 @@
 
 - name: Ensure that the rule runs with default parameters
+  tags:
+    - 'tests::tier1'
   hosts: all
 
   roles:
     - kdump
+
+  pre_tasks:
+    - name: Import tasks
+      tags: tests::tier1::cleanup
+      import_tasks: get_services_state.yml
+
+  post_tasks:
+    - name: Import tasks
+      tags: tests::tier1::cleanup
+      import_tasks: restore_services_state.yml
diff --git a/tests/tests_default_wrapper.yml b/tests/tests_default_wrapper.yml
index 2763fbd..617acb3 100644
--- a/tests/tests_default_wrapper.yml
+++ b/tests/tests_default_wrapper.yml
@@ -1,6 +1,9 @@
 ---
 - name: Create static inventory from hostvars
   hosts: all
+  tags:
+    - 'tests::tier1'
+    - 'tests::slow'
   tasks:
     - name: create temporary file
       tempfile:
@@ -17,10 +20,16 @@
 
 
 - name: Run tests_default.yml normally
+  tags:
+    - 'tests::tier1'
+    - 'tests::slow'
   import_playbook: tests_default.yml
 
 - name: Run tests_default.yml in check_mode
   hosts: all
+  tags:
+    - 'tests::tier1'
+    - 'tests::slow'
   tasks:
     - name: Run ansible-playbook with tests_default.yml in check mode
       command: ansible-playbook -vvv -i {{ tempinventory.path }} --check tests_default.yml