Fix linters and metadata

With update of ansible-lint to version >=6.0.0 a lot of new
linters were added, that enabled by default. In order to comply
with linter rules we're applying changes to the role.

With that we also update metdata to reflect current state.

Change-Id: I4aab8ba621228d3fbf79b1da8227be41f3258b5f
This commit is contained in:
Dmitriy Rabotyagov 2023-07-12 12:01:28 +02:00 committed by Dmitriy Rabotyagov
parent f3396119a4
commit b763b73ffc
7 changed files with 64 additions and 33 deletions

View File

@ -24,21 +24,21 @@ systemd_service_restart_changed: yes
systemd_tempd_prefix: tempd systemd_tempd_prefix: tempd
# Give a reasonable amount of time for the server to start up/shut down # Give a reasonable amount of time for the server to start up/shut down
systemd_TimeoutSec: 120 systemd_service_timeout_sec: "{{ systemd_TimeoutSec | default(120) }}"
systemd_Restart: on-failure systemd_service_restart: "{{ systemd_Restart | default('on-failure') }}"
systemd_RestartSec: 2 systemd_service_restart_sec: "{{ systemd_RestartSec | default(2) }}"
# Accounting options # Accounting options
systemd_CPUAccounting: true systemd_service_cpu_accounting: "{{ systemd_CPUAccounting | default(true) }}"
systemd_BlockIOAccounting: true systemd_service_block_io_accounting: "{{ systemd_BlockIOAccounting | default(true) }}"
systemd_MemoryAccounting: true systemd_service_memory_accounting: "{{ systemd_MemoryAccounting | default(true) }}"
systemd_TasksAccounting: true systemd_service_tasks_accounting: "{{ systemd_TasksAccounting | default(true) }}"
# Sandboxing options # Sandboxing options
systemd_PrivateTmp: false systemd_service_private_tmp: "{{ systemd_PrivateTmp | default(false) }}"
systemd_PrivateDevices: false systemd_service_private_devices: "{{ systemd_PrivateDevices | default(false) }}"
systemd_PrivateNetwork: false systemd_service_private_network: "{{ systemd_PrivateNetwork | default(false) }}"
systemd_PrivateUsers: false systemd_service_private_users: "{{ systemd_PrivateUsers | default(false) }}"
# Start service after a given target. This is here because we want to define common # Start service after a given target. This is here because we want to define common
# after targets used on most services. This can be overridden or agumented using # after targets used on most services. This can be overridden or agumented using
@ -138,7 +138,7 @@ systemd_environment: {}
# `bind_targets` -- (optional) Bind the socket to this dependency unit. # `bind_targets` -- (optional) Bind the socket to this dependency unit.
# `enabled` -- (optional) Set the enabled state of the socket. # `enabled` -- (optional) Set the enabled state of the socket.
# `options` -- (optional) Additional options, like `ListenStream` or other. Specifying ListenStream in # `options` -- (optional) Additional options, like `ListenStream` or other. Specifying ListenStream in
# the options will suppress the default 'Service' field in [Socket]. # the options will suppress the default 'Service' field in [Socket].
# `state` -- (optional) Set the running state of the socket. # `state` -- (optional) Set the running state of the socket.
# Under the service dictionary the "timer" key can be added which will enable a given service # Under the service dictionary the "timer" key can be added which will enable a given service

View File

@ -26,7 +26,7 @@
tags: tags:
- systemd-service - systemd-service
tags: tags:
- systemd-service - systemd-service
- name: Restart changed services - name: Restart changed services
@ -45,4 +45,4 @@
loop_control: loop_control:
loop_var: services_results loop_var: services_results
tags: tags:
- systemd-service - systemd-service

View File

@ -15,7 +15,10 @@
- name: "Restart service {{ services_results.item.service_name | replace(' ', '_') }}" - name: "Restart service {{ services_results.item.service_name | replace(' ', '_') }}"
systemd: systemd:
name: "{{ services_results.item.service_name | replace(' ', '_') }}{{ template_argument }}.{{ (services_results.item.timer is defined) | ternary('timer', 'service') }}" name: >-
{{ services_results.item.service_name | replace(' ', '_') }}{{ template_argument }}.{{
(services_results.item.timer is defined) | ternary('timer', 'service')
}}
state: restarted state: restarted
loop: "{{ services_results.item.template_arguments | default(['']) }}" loop: "{{ services_results.item.template_arguments | default(['']) }}"
loop_control: loop_control:

View File

@ -18,18 +18,20 @@ galaxy_info:
description: Installation and setup of systemd_service description: Installation and setup of systemd_service
company: Rackspace company: Rackspace
license: Apache2 license: Apache2
min_ansible_version: 2.0 role_name: systemd_service
namespace: openstack
min_ansible_version: "2.10"
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- buster - bullseye
- name: Ubuntu - name: Ubuntu
versions: versions:
- bionic
- focal - focal
- jammy
- name: EL - name: EL
versions: versions:
- 8 - "9"
categories: galaxy_tags:
- systemd - systemd
- development - development

View File

@ -0,0 +1,22 @@
---
deprecations:
- |
In order to follow ansible naming conventions for variables,
following variables were renamed:
* systemd_TimeoutSec -> systemd_service_timeout_sec
* systemd_Restart -> systemd_service_restart
* systemd_RestartSec -> systemd_service_restart_sec
* systemd_CPUAccounting -> systemd_service_cpu_accounting
* systemd_BlockIOAccounting -> systemd_service_block_io_accounting
* systemd_MemoryAccounting -> systemd_service_memory_accounting
* systemd_TasksAccounting -> systemd_service_tasks_accounting
* systemd_PrivateTmp -> systemd_service_private_tmp
* systemd_PrivateDevices -> systemd_service_private_devices
* systemd_PrivateNetwork -> systemd_service_private_network
* systemd_PrivateUsers -> systemd_service_private_users
Old variable names were kept for backwards compatibility but will be
removed in next releases. It is highly adviced to use new variable
names in your deployments.

View File

@ -141,9 +141,13 @@
systemd: systemd:
daemon_reload: yes daemon_reload: yes
when: when:
- (systemd_services_result is changed) or (systemd_timer_result is changed) or (systemd_override_result is changed ) or (systemd_socket.results | selectattr('changed', 'true') | length > 0) - (systemd_services_result is changed) or
(systemd_timer_result is changed) or
(systemd_override_result is changed ) or
(systemd_socket.results | selectattr('changed', 'true') | length > 0)
- include_tasks: systemd_load.yml - name: Including systemd_load tasks
include_tasks: systemd_load.yml
loop: "{{ systemd_services }}" loop: "{{ systemd_services }}"
loop_control: loop_control:
loop_var: service loop_var: service

View File

@ -65,10 +65,10 @@ ExecStopPost={{ execstoppost }}
{% endfor %} {% endfor %}
# Give a reasonable amount of time for the server to start up/shut down # Give a reasonable amount of time for the server to start up/shut down
TimeoutSec={{ systemd_TimeoutSec }} TimeoutSec={{ systemd_service_timeout_sec }}
{% if service_type != 'oneshot' %} {% if service_type != 'oneshot' %}
Restart={{ systemd_Restart }} Restart={{ systemd_service_restart }}
RestartSec={{ systemd_RestartSec }} RestartSec={{ systemd_service_restart_sec }}
{% endif %} {% endif %}
{% if item.standard_output is defined %} {% if item.standard_output is defined %}
@ -86,10 +86,10 @@ Slice={{ systemd_slice_name }}.slice
{{ key }}={{ value }} {{ key }}={{ value }}
{% endfor %} {% endfor %}
{% else %} {% else %}
CPUAccounting={{ systemd_CPUAccounting }} CPUAccounting={{ systemd_service_cpu_accounting }}
BlockIOAccounting={{ systemd_BlockIOAccounting }} BlockIOAccounting={{ systemd_service_block_io_accounting }}
MemoryAccounting={{ systemd_MemoryAccounting }} MemoryAccounting={{ systemd_service_memory_accounting }}
TasksAccounting={{ systemd_TasksAccounting }} TasksAccounting={{ systemd_service_tasks_accounting }}
{% endif %} {% endif %}
{% if service_type != 'oneshot' %} {% if service_type != 'oneshot' %}
@ -99,15 +99,15 @@ TasksAccounting={{ systemd_TasksAccounting }}
{{ key }}={{ value }} {{ key }}={{ value }}
{% endfor %} {% endfor %}
{% else %} {% else %}
PrivateTmp={{ systemd_PrivateTmp }} PrivateTmp={{ systemd_service_private_tmp }}
PrivateDevices={{ systemd_PrivateDevices }} PrivateDevices={{ systemd_service_private_devices }}
PrivateNetwork={{ systemd_PrivateNetwork }} PrivateNetwork={{ systemd_service_private_network }}
{# NOTE(cloudnull): Limit the use of PrivateUsers {# NOTE(cloudnull): Limit the use of PrivateUsers
The systemd directive "PrivateUsers" was implemented in systemd version 232. The systemd directive "PrivateUsers" was implemented in systemd version 232.
To correct a lot of spam messages in the journal the default directive is 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 #} limited when to systemd version greater than or equal to 232 #}
{% if (systemd_version | int) >= 232 %} {% if (systemd_version | int) >= 232 %}
PrivateUsers={{ systemd_PrivateUsers }} PrivateUsers={{ systemd_service_private_users }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if systemd_version|int >= 235 and item.state_directory is defined %} {% if systemd_version|int >= 235 and item.state_directory is defined %}