ansible/test/integration/targets/service/tasks/main.yml
Rick Elrod 44a471f6ba
Enable service integration tests for FreeBSD (#68980)
* Enable service integration tests for FreeBSD

Change:
Adds necessary rc file for freebsd, and gets tests passing for it.

Test Plan:
Ran test with `--remote freebsd/12.1` and `--remote freebsd/11.1`. Both
passed.

Signed-off-by: Rick Elrod <rick@elrod.me>

* Update test/integration/targets/service/tasks/rc_setup.yml

Co-Authored-By: Matt Clay <matt@mystile.com>

* fix up comment

Signed-off-by: Rick Elrod <rick@elrod.me>

Co-authored-by: Matt Clay <matt@mystile.com>
2020-04-17 10:41:08 -07:00

58 lines
2 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

- name: install the test daemon script
copy:
src: ansible_test_service.py
dest: /usr/sbin/ansible_test_service
mode: '755'
- name: rewrite shebang in the test daemon script
lineinfile:
path: /usr/sbin/ansible_test_service
line: "#!{{ ansible_python_interpreter | realpath }}"
insertbefore: BOF
firstmatch: yes
- block:
# 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
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'
- name: detect upstart init system
set_fact:
service_type: upstart
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_version is version('15.04', '<')
- name: detect rc init system
set_fact:
service_type: rc
when:
- ansible_distribution.lower().endswith('bsd')
- 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'