Correct log warning for unknown lvalue

The default systemd service template was using the PrivateUsers
directive by default which was only implemented in systemd version 232.
Because we're running on older versions of systemd in a lot of cases the
this option was creating a log of journal spam. To correct the issue the
version of systemd is now detected and this default option will only be
used when the version of systemd is greater than or equal to version
232.

Change-Id: Ief1a2e155892ab7df821fbf049787e705da91b40
Closes-Bug: #1776818
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-07-16 11:21:06 -05:00
parent 20399a1a86
commit 94ff90157a
No known key found for this signature in database
GPG Key ID: 9443251A787B9FB3
2 changed files with 21 additions and 0 deletions

View File

@ -13,6 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Pull systemd version
command: "systemctl --version"
changed_when: false
register: get_systemd_version
tags:
# Avoid ANSIBLE0006 lint issue: systemctl used in place of systemd module
- skip_ansible_lint
- always
- name: Set systemd version
set_fact:
systemd_version: "{{ get_systemd_version.stdout_lines[0].split()[-1] }}"
tags:
- always
- name: Create TEMP run dir
file:
path: "/var/run/{{ item.service_name | replace(' ', '_') }}"

View File

@ -73,7 +73,13 @@ TasksAccounting={{ systemd_TasksAccounting }}
PrivateTmp={{ systemd_PrivateTmp }}
PrivateDevices={{ systemd_PrivateDevices }}
PrivateNetwork={{ systemd_PrivateNetwork }}
{# NOTE(cloudnull): Limit the use of PrivateUsers
The systemd directive "PrivateUsers" was implemented in systemd version 232.
To correct a lot of spam messages in the journal the default directive is
limited when to systemd version greater than or equal to 232 #}
{% if (systemd_version | int) >= 232 %}
PrivateUsers={{ systemd_PrivateUsers }}
{% endif %}
{% endif %}
{% endif %}