1f7091a11c
This functionality is pretty neat and used widely if you need to pass specific argument to the unit service, but rest of the parameters can be left intact. Change-Id: I6eb80ac0f9f0257402697a255518bb2c66d0dfd5
93 lines
2.9 KiB
YAML
93 lines
2.9 KiB
YAML
---
|
|
# Copyright 2015, Rackspace US, Inc.
|
|
# Copyright 2018, Logan Vig <logan2211@gmail.com>
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Playbook for role testing
|
|
hosts: localhost
|
|
connection: local
|
|
user: root
|
|
become: true
|
|
roles:
|
|
- role: "systemd_service"
|
|
systemd_services:
|
|
- service_name: "test simple service0"
|
|
execstarts: "/bin/bash -c 'while true; do sleep 2 && echo test simple service; done'"
|
|
enabled: yes
|
|
- service_name: "test simple service0 with env vars"
|
|
execstarts: "/bin/bash -c 'while true; do sleep 2 && echo $ENV_VAR1; done'"
|
|
enabled: yes
|
|
environment:
|
|
ENV_VAR1: "testing"
|
|
- service_name: "test oneshot service1"
|
|
config_overrides:
|
|
Unit:
|
|
Description: Test oneshot service
|
|
After: network-online.target
|
|
Wants: network-online.target
|
|
Service:
|
|
RemainAfterExit: yes
|
|
service_type: oneshot
|
|
execstarts:
|
|
- "/bin/bash -c 'echo start1'"
|
|
- "/bin/bash -c 'echo start2'"
|
|
execstops:
|
|
- "/bin/bash -c 'echo stop1'"
|
|
- "/bin/bash -c 'echo stop2'"
|
|
enabled: yes
|
|
state: started
|
|
systemd_tempd_prefix: openstack
|
|
- service_name: "test timer service0"
|
|
execstarts:
|
|
- "/bin/bash -c 'echo start0'"
|
|
timer:
|
|
state: "started"
|
|
options:
|
|
OnBootSec: 30min
|
|
OnUnitActiveSec: 1h
|
|
Persistent: true
|
|
- service_name: "test timer service1"
|
|
execstarts:
|
|
- "/bin/bash -c 'echo start1'"
|
|
timer:
|
|
state: "started"
|
|
cron_minute: 30
|
|
cron_hour: 1
|
|
- service_name: "test_templated_service@"
|
|
service_type: oneshot
|
|
execstarts:
|
|
- "/bin/bash -c 'echo %i'"
|
|
template_arguments:
|
|
- 1
|
|
- 2
|
|
enabled: yes
|
|
state: started
|
|
|
|
post_tasks:
|
|
- name: Check Services
|
|
command: systemctl status "{{ item }}"
|
|
changed_when: false
|
|
with_items:
|
|
- test_simple_service0
|
|
- test_simple_service0_with_env_vars
|
|
- test_oneshot_service1
|
|
- test_timer_service0.timer
|
|
- test_timer_service1.timer
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Notify tests passed
|
|
debug:
|
|
msg: All tests have passed
|