Fix global lock path usage

The option `systemd_lock_path` is intended to be set globally
and locally however the global implementation has never been
implemented.

  * The global option will ensure the run and lock path is setup
    for all services within the `systemd_services` array.
  * The local option provices a way to override a global lock path
    based on specific service needs.

Change-Id: I373b8905c01ff666b5705bd3bb3c76c3e74a64ab
This commit is contained in:
Kevin Carter 2018-11-26 11:38:13 -06:00 committed by Kevin Carter
parent f79988efca
commit 86ad639f41
3 changed files with 11 additions and 4 deletions

View File

@ -62,6 +62,11 @@ systemd_service_config_overrides: {}
# https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=
systemd_default_service_type: simple
# Global lock path used for system services.
# This is an optional variable and will have no effect if undefined.
# This option can also be defined for specific service entries under "systemd_services".
# systemd_lock_path: "/var/lock/service1"
# 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.

View File

@ -52,13 +52,14 @@
- name: Create TEMP defined lock dir
file:
path: "{{ item.systemd_lock_path }}"
path: "{{ item.systemd_lock_path | default(systemd_lock_path) }}"
state: directory
owner: "{{ item.systemd_user_name | default(systemd_user_name) }}"
group: "{{ item.systemd_group_name | default(systemd_group_name) }}"
mode: "02755"
when:
- item.systemd_lock_path is defined
- (item.systemd_lock_path is defined) or
(systemd_lock_path is defined)
with_items: "{{ systemd_services }}"
tags:
- systemd-service

View File

@ -1,7 +1,8 @@
# {{ ansible_managed }}
{% if item.systemd_lock_path is defined %}
D {{ item.systemd_lock_path }} 2755 {{ item.systemd_user_name | default(systemd_user_name) }} {{ item.systemd_group_name | default(systemd_group_name) }}
{% if (item.systemd_lock_path is defined) or (systemd_lock_path is defined) %}
D {{ item.systemd_lock_path | default(systemd_lock_path) }} 2755 {{ item.systemd_user_name | default(systemd_user_name) }} {{ item.systemd_group_name | default(systemd_group_name) }}
D {{ (item.systemd_lock_path | default(systemd_lock_path)) | replace('lock', 'run') }} 2755 {{ item.systemd_user_name | default(systemd_user_name) }} {{ item.systemd_group_name | default(systemd_group_name) }}
{% endif %}
D /var/lock/{{ item.service_name | replace(' ', '_') }} 2755 {{ item.systemd_user_name | default(systemd_user_name) }} {{ item.systemd_group_name | default(systemd_group_name) }}
D /var/run/{{ item.service_name | replace(' ', '_') }} 2755 {{ item.systemd_user_name | default(systemd_user_name) }} {{ item.systemd_group_name | default(systemd_group_name) }}