LPS:CFEngine3/hands-on

Z HelpDesk

Instalace

echo "deb http://cfengine.com/pub/apt stable main" >> /etc/apt/sources.list
apt-get update
apt-get install cfengine-community

Co jsme získali?

/var/cfengine/

  • inputs
  • masterfiles

Prvni kontakt

cf-agent --bootstrap cf.civ.zcu.cz

Ukázkové bundly

Hello world

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

bundle agent main {
reports:
  verbose::
    "Hello World";
}
cf-agent -Kf ./test1.cf 
cf-agent -Kf ./test1.cf -D verbose

New file

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

bundle agent main {
vars:
  any::
    "file"
      string => "/tmp/cftest.txt";

classes:
  any::
    "file_exists"
      expression => fileexists("$(file)");

files:
  any::
    "/tmp/cftest.txt"
      create => "true",
      classes => if_repaired("file_created");

reports:
  file_exists::
    "Soubor existuje"

  file_created::
    "Soubor byl vytvoren"
}