Sunday 24 April 2016

Getting started with CFEngine part 3 (some useful commands)



This is a brief tutorial about some easy & useful CFEngine commands.

To view the installed version of CFEngine:


[root@dockertest init.d]# /var/cfengine/bin/cf-agent -V
CFEngine Core 3.7.3

CFEngine Enterprise 3.7.3

Keys are necessary when operating in a distributed CFEngine environment. The below command also sets up under /var/cfengine/ the basic directory structure used by CFEngine. To set up the keys type:

[root@dockertest ~]# /var/cfengine/bin/cf-key
A key file already exists at /var/cfengine/ppkeys/localhost.pub

Bootstraping:

Bootstraping the agent means copying the masterfiles to their final working location in /var/cfengine/inputs/ and starting the base cf-execd daemon. This process controls the periodic execution of cf-agent, which is the one that actually executes the promises in the provided policies 

[root@cfeclient tmp]# /var/cfengine/bin/cf-agent --bootstrap --policy-server 192.168.44.179
 warning: Deprecated bootstrap options detected. The --policy-server (-s) option is deprecated from CFEngine community version 3.5.0.Please provide the address argument to --bootstrap (-B) instead. Rewriting your arguments now, but you need to adjust them as this support will be removed soon.
  notice: Bootstrap mode: implicitly trusting server, use --trust-server=no if server trust is already established
R: Bootstrapping from host '192.168.44.179' via built-in policy '/var/cfengine/inputs/failsafe.cf'
R: This autonomous node assumes the role of voluntary client
R: Updated local policy from policy server
R: Did not start the scheduler
  notice: Bootstrap to '192.168.44.179' completed successfully!

To check the status of cfagent run the following command:

[root@dockertest init.d]# ./cfengine3 status
cf-consumer (pid 4875 4874 4873 4872 4871 4870 4869 4868 4867 4866 4865 4864 4863 4862 4861 4860 4859 4858 4857 4856 4855 4854 4853 4852 4851 4848) is running...
cf-hub (pid 4906) is running...
redis-server (pid 4841) is running...
httpd (pid 4986 4985 4984 4983 4982 4833) is running...
postgres is not running
cf-execd (pid 4964) is running...
cf-serverd (pid 4970) is running...
cf-monitord (pid 4976) is running...


To restart the agent type:

[root@dockertest init.d]# ./cfengine3 restart
Shutting down runalerts.sh
Starting CFEngine postgresql-hub:
waiting for server to start.... done
server started

Starting CFEngine httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.44.179 for ServerName

Starting redis-server...
Starting cf-consumer...                                    [  OK  ]
Starting cf-hub...                                         [  OK  ]
Starting cf-execd...                                       [  OK  ]
Starting cf-serverd...                                     [  OK  ]
Starting cf-monitord...                                    [  OK  ]
[root@dockertest init.d]#                                  [  OK  ]


To print verbose information about the behavior of the agent type:

cf-agent -v
------------------ output truncated
 verbose: Diff is empty, nothing to save at '/var/cfengine/state/diff/lastseen.diff'
 verbose: Diff is empty, nothing to save at '/var/cfengine/state/diff/software.diff'
 verbose: Diff is empty, nothing to save at '/var/cfengine/state/diff/patch.diff'
 verbose: No lock purging scheduled
 verbose: Outcome of version CFEngine Promises.cf 3.7.3 (agent-0): Promises observed - Total promise compliance: 100% kept, 0% repaired, 0% not kept (out of 212 events). User promise compliance: 100% kept, 0% repaired, 0% not kept (out of 192 events). CFEngine system compliance: 100% kept, 0% repaired, 0% not kept (out of 20 events).

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...