From 70539b4c1cfa4e0e00bbf2d41234c666cf0e9750 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Mon, 22 May 2017 21:55:20 -0500 Subject: [PATCH] added additional docs Signed-off-by: Kevin Carter --- defaults/main.yml | 13 +++++++++++++ tasks/main.yml | 9 +++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 7832542..1ad6692 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -43,12 +43,20 @@ systemd_after_targets: - syslog.target - network.target +# Set the service state. Valid options are: [started, stopped, restarted, reloaded]. +systemd_service_state: started + +# Set the service enabled state. Valid options are: [yes, no] +systemd_service_enabled: yes + # The systemD services dictionary is a set of services that will be created. The dictionary # can contain the following options: # `service_name` -- (required) used to define the name of the service. This is typically the name of the executable. # `init_config_overrides` -- (optional) This allows any section or key=value pair to be set within the systemd unit file. # `program_config_options` -- (optional) Provides the ability to pass in flags to a given service for execution. # `program_override` -- (optional) sets the full path to the executable that will be run by the service file. +# `enabled` -- (optional) Set the enabled state of the service. +# `state` -- (optional) Set the running state of the service. # Examples: # systemd_services: @@ -63,5 +71,10 @@ systemd_after_targets: # service_name: ServiceY # init_config_overrides: {} # This is used to add in arbitratry unit file options # program_override: '/usr/bin/ServiceY' +# ServiceZ: +# service_name: ServiceZ +# init_config_overrides: {} # This is used to add in arbitratry unit file options +# enabled: no +# state: stopped systemd_services: {} diff --git a/tasks/main.yml b/tasks/main.yml index ef760c7..979976e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -60,10 +60,11 @@ - systemd-init - name: Load service - service: - name: "{{ item.value.service_name }}" - enabled: "yes" - state: "started" + systemd: + name: "{{ item.value.service_name }}" + daemon_reload: yes + enabled: "{{ item.value.enabled | default(systemd_service_enabled) }}" + state: "{{ item.value.service_state | default(systemd_service_state) }}" with_dict: "{{ systemd_services }}" tags: - systemd-init