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

Standard services with policy restart does not restart if service is not running

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.6
    • Component/s: Promise type: services
    • Labels:
      None
    • Platform:
      Linux
    • Steps to reproduce:
      Manual steps provided

      Description

      From the mailing list "Bernt Jernberg wrote":https://groups.google.com/forum/#!searchin/help-cfengine/$20standard_services$20and$20restart$20again/help-cfengine/OttjcyiJMv8/iXbvLbEXxoAJ

      > On a RHEL 6.6 running Community 3.6.5 I have this in my library:
      >
      <pre>
      bundle agent update_service_m(src,dst,m,svc)
      {
      files:
      "$(dst)"
      comment => "Sync $(dst)",
      copy_from => local_dcp("$(src)"),
      classes => if_repaired("$(dst)_restart");

      "$(dst)"
      comment => "Correct permissions on $(dst)",
      perms => system_owned("$(m)"),
      classes => if_repaired("$(dst)_update");

      methods:
      "Restart $(svc)" usebundle => standard_services("$(svc)","restart"),
      ifvarclass => canonify("$(dst)_restart");

      reports:
      "$(dst) updated"
      ifvarclass => canonify("$(dst)_restart");

      "Permission on $(dst) corrected"
      ifvarclass => canonify("$(dst)_update");
      }
      </pre>
      >
      >
      > I call it like this to update sshd_config:
      >
      >
      <pre>
      bundle agent update_sshd_config
      {
      vars:
      "src" strinng => "$(g.cache_files)/etc.ssh.sshd_config";
      "dest" strinng => "/etc/ssh/sshd_config";
      "mode" strinng => "0600";
      "service" strinng => "sshd";

      methods:
      "Update file" usebundle => update_service_m("$(src)",
      "$(dst)",
      "$(mode)",
      "$(service)");
      }
      </pre>
      >
      > Restart never works if the service is not started. If I in lib/3.6/services.cf:
      >
      > change the line:
      >
      <pre>
      chkconfig.have_init.((start.!running)|((stop|restart|reload).running)).non_disabling::
      </pre>
      >
      > to
      >
      <pre>
      chkconfig.have_init.(((start|restart).!running)|((stop|restart|reload).running)).non_disabling::
      </pre>
      >
      > it works. This may have been discussed already according to https://dev.cfengine.com/issues/6492

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                a10042 Nick Anderson
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel