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
This commit is contained in:
Jonathan Rosser 2023-10-10 14:41:31 +01:00
parent 9e96739c85
commit 1beb241764
2 changed files with 2 additions and 24 deletions

View File

@ -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(' ', '_') }}"

View File

@ -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 %}