Skip to content

[BUG] Formula try do enable for all unittypes #64

Open
@unix196

Description

@unix196

Formula support this unittypes - https://github.com/saltstack-formulas/systemd-formula/blob/master/systemd/units/unittypes.yaml.
In this state https://github.com/saltstack-formulas/systemd-formula/blob/master/systemd/units/init.sls#L21 formula try doing enable for all types, but it is not always possible to do this, for example:

systemctl cat browser.target
[Install]
WantedBy=multi-user.target

[Unit]
After=network.target
Description=Chromium target
[email protected]
[email protected]
[email protected]

systemctl cat [email protected]
[Service]
ExecStart=some_command
Group=chromium
...
Slice=chromium.slice
Type=simple

[Unit]
After=network.target
Description=Browser runner %i
PartOf=browser-runner.target


systemctl cat chromium.slice
[Slice]
MemoryLimit=20G

[Unit]
Before=slices.target
DefaultDependencies=False
Description=Limited resources for Chromiums

I can enable target unit, but this action not valid for the current config service(service with multiple instances) and slice units. Code where define unit_status. I think can be done like this:

systemd/units/init.sls
 -     {% set unit_status = 'disable' if unitconfig.enabled is defined and unitconfig.enabled == false else 'enable' %}
+ {#      {% set unit_status = 'disable' if unitconfig.enabled is defined and unitconfig.enabled == false else 'enable' %} #}
...
+      {% if unitconfig.enabled is defined %}
 +     {% set unit_status = 'disable' if unitconfig.enabled == false else 'enable' %}
systemd_systemd_units_cmd_enable_or_disable_{{ unit }}_{{ unittype }}:
  cmd.wait:
    - name: systemctl {{ unit_status }} {{ unit }}.{{ unittype }}
    - watch:
      - cmd: reload_systemd_configuration
+      {% endif %}

In pillar explicitly define enabled variable.
This way state will try enable only necessary unittypes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions