From 1beb2417645c6c43b53413948077aad44e873185 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Tue, 10 Oct 2023 14:41:31 +0100 Subject: [PATCH] Remove conditions on systemd version All the supported platforms are now using more modern systemd versions than detected with the logic in this role, so remove the redundant tasks and conditions. Change-Id: I0ddaefc575f1b0cbf85696cde25aa69907fede9f --- tasks/main.yml | 16 ---------------- templates/systemd-service.j2 | 10 ++-------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 2698b37..37a72f0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,22 +13,6 @@ # 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 - check_mode: no - 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: "{{ item.systemd_run_dir | default(systemd_run_dir) }}/{{ item.systemd_slice_name | default(systemd_slice_name) | replace(' ', '_') }}" diff --git a/templates/systemd-service.j2 b/templates/systemd-service.j2 index c97f6c4..e433be8 100644 --- a/templates/systemd-service.j2 +++ b/templates/systemd-service.j2 @@ -20,7 +20,7 @@ Type={{ service_type }} User={{ item.systemd_user_name | default(systemd_user_name) }} Group={{ item.systemd_group_name | default(systemd_group_name) }} -{% if systemd_version|int >= 235 and item.dynamic_user is defined %} +{% if item.dynamic_user is defined %} DynamicUser={{ item.dynamic_user|bool }} {% endif %} @@ -102,15 +102,9 @@ TasksAccounting={{ systemd_service_tasks_accounting }} PrivateTmp={{ systemd_service_private_tmp }} PrivateDevices={{ systemd_service_private_devices }} PrivateNetwork={{ systemd_service_private_network }} -{# 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_service_private_users }} -{% endif %} {% endif %} -{% if systemd_version|int >= 235 and item.state_directory is defined %} +{% if item.state_directory is defined %} StateDirectory={{ item.state_directory }} {% endif %} {% endif %}