Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3009

Agent tries to disable static units

    XMLWordPrintable

    Details

      Description

      Hi,

      The fix for CFE-2923 seems to cause cfengine to try to disable static services (which does not work, static services cannot be enabled/disabled with systemctl enable/disable). This is harmless, but annoying as it will cause the promise to be repaired each run.

      From lib/services.cf:

       

            "service_enabled" expression => reglist(@(systemd_service_info), "UnitFileState=enabled");
      {{      "service_enabled" -> { "CFE-2923" }}}
              expression => returnszero( "$(call_systemctl) is-enabled $(service) > /dev/null 2>&1", useshell);

       

       

      Because is-enabled returns 0 with static services, but outputs "static" instead of "enabled", for example{{ with a known static service that should be available everywhere}}:

       

      # systemctl is-enabled ntpd.service; echo $?
      enabled
      0
      # systemctl is-enabled systemd-tmpfiles-setup.service; echo $?
      static
      0

       

      The first check with UnitFileState is enough in this case as it doesn't match UnitFileState=enabled:

       

      # systemctl -pUnitFileState show systemd-tmpfiles-setup.service
      UnitFileState=static

       

      Maybe the second check should be done only when UnitFileState=bad?

      Thanks.

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            mrpouit Lionel Le Folgoc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: