* Enabled more tests in test_service on systems with systemd.
* Fix inconsistency in cleaning up test service. The conditions for service setup and service cleanup were different.
* Add check mode run for service enable.
pull/16419/head
Gennady Trafimenkov8 years agocommitted byMatt Clay
when:ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and (ansible_distribution_version|version_compare('6', '>=') and ansible_distribution_version|version_compare('7', '<'))
- include:'systemd_setup.yml'
- name:detect systemd init system
set_fact:service_type=systemd
when:(ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and (ansible_distribution_version|version_compare('7', '>=') and ansible_distribution_version|version_compare('8', '<'))) or ansible_distribution == 'Fedora' or (ansible_distribution == 'Ubuntu' and ansible_distribution_version|version_compare('15.04', '>=')) or (ansible_distribution == 'Debian' and ansible_distribution_version|version_compare('8', '>=')) or ansible_os_family == 'Suse'
- include:'upstart_setup.yml'
- name:detect upstart init system
set_fact:service_type=upstart
when:ansible_distribution == 'Ubuntu' and ansible_distribution_version|version_compare('15.04', '<')
# setup test service script
- include:'sysv_setup.yml'
when:service_type == "sysv"
- include:'systemd_setup.yml'
when:service_type == "systemd"
- include:'upstart_setup.yml'
when:service_type == "upstart"
- name:disable the ansible test service
service:name=ansible_test enabled=no
- name:(check mode run) enable the ansible test service
service:name=ansible_test enabled=yes
register:enable_in_check_mode_result
check_mode:yes
- name:assert that changes reported for check mode run
assert:
that:
- "enable_in_check_mode_result.changed == true"
- name:enable the ansible test service
service:name=ansible_test enabled=yes
register:enable_result
- name:assert that the service was enabled
- name:assert that the service was enabled and changes reported