saltstack-formulas/systemd-formula

enable_{{ unit }}_{{ unittype}} fails for systemd path units.

r-pufky opened this issue ยท 2 comments

The enable state does not include the unittype, hence when creating a path based-unit, enable will fail, as systemctl assumes .service.

systemd:
  path:
    test_watch_changes:
      Path:
        PathModified: /path/to/monitor
        Unit: some_service_to_trigger.service
      Install:
        WantedBy: multi-user.target

This will result in the following error when applying the state:

----------
          ID: enable_test_watch_changes_path
    Function: cmd.wait
        Name: systemctl enable test_watch_changes
      Result: False
     Comment: Command "systemctl enable test_watch_changes" run
     Started: 19:19:58.136892
    Duration: 7.458 ms
     Changes:

Fix

Did a quick patch and tested with service, path definitions.

  | @@ -18,7 +18,7 @@ include:
-- | --
18 | 18 |  
19 | 19 | enable_{{ unit }}_{{ unittype }}:
20 | 20 | cmd.wait:
21 |   | -    - name: systemctl enable {{ unit }}
  | 21 | +    - name: systemctl enable {{ unit }}.{{ unittype }}
22 | 22 | - watch:
23 | 23 | - cmd: reload_systemd_configuration

@r-pufky can you create a PR for this change so we all can benefit?

๐ŸŽ‰ This issue has been resolved in version 0.12.3 ๐ŸŽ‰

The release is available on GitHub release

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€