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 af0b2a0..6ce5241 100644 --- a/tests/tests_default.yml +++ b/tests/tests_default.yml @@ -3,3 +3,13 @@ roles: - linux-system-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 eba31a0..857aab8 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: > diff --git a/tests/tests_ssh.yml b/tests/tests_ssh.yml index d12e884..6d3699c 100644 --- a/tests/tests_ssh.yml +++ b/tests/tests_ssh.yml @@ -10,6 +10,13 @@ # this is the address at which the ssh dump server can be reached # from the managed host. Dumps will be uploaded there. kdump_ssh_server_inside: "{{ kdump_ssh_source if kdump_ssh_source in hostvars[kdump_ssh_server_outside]['ansible_all_ipv4_addresses'] + hostvars[kdump_ssh_server_outside]['ansible_all_ipv6_addresses'] else hostvars[kdump_ssh_server_outside]['ansible_default_ipv4']['address'] }}" + tags: + # this test executes some tasks on localhost and relies on + # localhost being a different host than the managed host + # (localhost is being used as a second host in multihost + # scenario). This also means that localhost must be capable + # enough (not just a container - must be runnign a sshd). + - 'tests::multihost_localhost' tasks: - name: gather facts from {{ kdump_ssh_server_outside }} diff --git a/tests/tests_ssh_wrapper.yml b/tests/tests_ssh_wrapper.yml index 2203f3f..96a764e 100644 --- a/tests/tests_ssh_wrapper.yml +++ b/tests/tests_ssh_wrapper.yml @@ -1,6 +1,8 @@ --- - name: Create static inventory from hostvars hosts: all + tags: + - 'tests::slow' tasks: - name: create temporary file tempfile: @@ -17,10 +19,15 @@ - name: Run tests_ssh.yml normally + tags: + - 'tests::slow' import_playbook: tests_ssh.yml - name: Run tests_ssh.yml in check_mode hosts: all + tags: + - 'tests::slow' + - 'tests::multihost_localhost' tasks: - name: Run ansible-playbook with tests_ssh.yml in check mode command: |