2020-08-07 21:28:10 +02:00
- name : skip unsupported distros
meta : end_host
when : ansible_distribution in ['Alpine']
2014-02-20 00:05:35 +01:00
- name : install the test daemon script
2019-03-27 19:36:07 +01:00
copy :
src : ansible_test_service.py
dest : /usr/sbin/ansible_test_service
mode : '755'
2014-02-20 00:05:35 +01:00
2019-03-27 19:36:07 +01:00
- name : rewrite shebang in the test daemon script
lineinfile :
path : /usr/sbin/ansible_test_service
line : "#!{{ ansible_python_interpreter | realpath }}"
insertbefore : BOF
firstmatch : yes
2018-08-08 06:48:03 +02:00
2019-03-27 19:36:07 +01:00
- block :
2018-08-08 06:48:03 +02:00
# determine init system is in use
- name : detect sysv init system
set_fact :
service_type : sysv
when :
- ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
- ansible_distribution_version is version('6', '>=')
- ansible_distribution_version is version('7', '<')
- name : detect systemd init system
set_fact :
service_type : systemd
2018-12-06 00:07:18 +01:00
when : (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version is version('7', '>=')) or ansible_distribution == 'Fedora' or (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('15.04', '>=')) or (ansible_distribution == 'Debian' and ansible_distribution_version is version('8', '>=')) or ansible_os_family == 'Suse'
2018-08-08 06:48:03 +02:00
- name : detect upstart init system
set_fact :
service_type : upstart
when :
- ansible_distribution == 'Ubuntu'
- ansible_distribution_version is version('15.04', '<')
2020-04-17 19:41:08 +02:00
- name : detect rc init system
set_fact :
service_type : rc
when :
- ansible_distribution.lower().endswith('bsd')
2018-08-08 06:48:03 +02:00
- name : display value of ansible_service_mgr
debug :
msg: 'ansible_service_mgr : {{ ansible_service_mgr }}'
- name : setup test service script
include_tasks : '{{ service_type }}_setup.yml'
- name : execute tests
import_tasks : tests.yml
always :
- name : disable and stop ansible test service
service :
name : ansible_test
state : stopped
enabled : false
# cleaning up changes made by this playbook
- include_tasks : '{{ service_type }}_cleanup.yml'