refactor ♻️: Refactor ExecStart to use a list for commands and conditionally execute them.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This refactoring involves restructuring the `ExecStart` method to utilize a list of commands instead of a single string. This change allows for more flexible execution based on certain conditions, enhancing the modularity and maintainability of the code.
This commit is contained in:
@@ -5,8 +5,13 @@ Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash -c '{% for intf, enabled, supported in en_interfaces | zip(wol_enabled.results, wol_supported.results) %}
|
||||
{% if wol_mode in supported.stdout and wol_mode not in enabled.stdout %}/sbin/ethtool -s {{ intf }} wol {{ wol_mode }}; {% endif %}{% endfor %}'
|
||||
ExecStart=/bin/bash -c '{% set cmds = [] %}
|
||||
{% for intf, enabled, supported in en_interfaces | zip(wol_enabled.results, wol_supported.results) %}
|
||||
{% if wol_mode in supported.stdout and wol_mode not in enabled.stdout %}
|
||||
{% set _ = cmds.append("/sbin/ethtool -s " ~ intf ~ " wol " ~ wol_mode) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ cmds | join("; ") if cmds | length > 0 else ":" }}'
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
|
||||
Reference in New Issue
Block a user