Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
unix196 opened this issue Jan 13, 2021 · 0 comments
Open

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

unix196 opened this issue Jan 13, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@unix196
Copy link

unix196 commented Jan 13, 2021

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
Wants=browser-runner@1.service
Wants=browser-runner@2.service
Wants=browser-runner@3.service

systemctl cat browser-runner@.service
[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.

@unix196 unix196 added the bug Something isn't working label Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant