0

I'm new with cfengine. I created a simple promise that creates a file named testing into /etc/test-cfengine

body common control
{
bundlesequence =>{"create_test_file"};
}


bundle agent create_test_file
{
    files:
            "/etc/test-cfengine/test-file"

            edit_line => addline,
            create => "true";
}

bundle edit_line addline
{
    insert_lines: "Cfengine is running nicely.";
}

When I run cf-agent -K (after editing promises.cf and including the promise) I notice that test-file exists in /etc/test-cfengine. But when I go to the client I notice that the promise exists, but the test-file does not.

So the promise is propagating to the clients, but not triggering.

How can I be sure that the file exists in all the clients?

0

More information is needed to debug the problem, so you can check for the following in the given order:

  • On the hub side, where did you edit promises.cf? The proper place is in /var/cfengine/masterfiles, not in /var/cfengine/inputs where the file will be overwritten soon.
  • Did you wait 5 min for the policy to propagate and run? (these are two separate steps)
  • On the client side, check /var/cfengine/inputs/promises.cf. Is it the same as in /var/cfengine/masterfiles/promises.cf on the hub? If so, the policy propagated correctly.
  • If still failing, tail /var/log/messages. Do you see any messages coming from CFEngine every 5 minutes?
  • Try running the policy manually: cf-agent -KI. What is the output? Is the file created now?
  • Soon after posting this question I realized I was editing the policy into /inputs/ directory rather than /masterfiles/ like I thought. – wOvalle Mar 12 '15 at 18:10
0

This should work both on policy server (hub) and all connected clients and file should be created everywhere. The reason why you can not see the file after the policy is already propagated to agent is probably because cf-agent on the client didn't run yet and thus file was not created.

It should be created after next cf-agent run which should happen within 5 minutes (default configuration).

If you want to have the file created earlier you can simply run cf-agent -KI on the client and the output should indicate file creation.

And to explain how this stuff works:

1. You modify policy on hub
2. Policy from hub masterfiles is copied to hub inputs directory (every 5 minutes cf-execd is running cf-agent -f update.cf to copy
the policy from mastefiles)
3. After policy is there within next 5 minutes cf-agent is running and executing policy
4. In the meantime clients are contacting hub to check if policy has changed
5. If so clients are downloading policy to inputs
6. After 5 minutes cf-agent is run and policy is executed

Hope this helps to understand the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.