diff --git a/tasks/main.yml b/tasks/main.yml index 145e9f7..4163a46 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 %}