Merge "Remove conditions on systemd version"

This commit is contained in:
Zuul 2023-10-17 17:41:14 +00:00 committed by Gerrit Code Review
commit 2ce606c40a
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 %}