diff --git a/tasks/main.yml b/tasks/main.yml index abcb17e..705e792 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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(' ', '_') }}" diff --git a/templates/systemd-service.j2 b/templates/systemd-service.j2 index da2b0f3..a5c70ef 100644 --- a/templates/systemd-service.j2 +++ b/templates/systemd-service.j2 @@ -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 %}