--- # Copyright 2015, Rackspace US, Inc. # Copyright 2018, Logan Vig # # 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 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