Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #failsafe.cf
- bundle common g
- {
- vars:
- "masterfiles" string => "/var/cfengine/masterfiles";
- "phost" string => "17.17.0.28"; # Do NOT use DNS here in case we break DNS resolution.
- }
- body common control
- {
- bundlesequence => { "update" };
- inputs => { "update.cf" };
- }
- # site.cf
- bundle common g
- {
- vars:
- "masterfiles" string => "/var/cfengine/masterfiles";
- "phost" string => "cf0.xxx.xxx";
- SuSE::
- "crontab" string => "/var/spool/cron/tabs/root";
- !SuSE::
- "crontab" string => "/var/spool/cron/crontabs/root";
- }
- bundle agent main
- {
- vars:
- "blacklisted_packages"
- slist => {
- "NetworkManager"
- };
- "standard_packages"
- slist => {
- "bind-utils",
- "check_mk-agent",
- "check_mk-agent-logwatch",
- "man",
- "mlocate",
- "mtr",
- "nano",
- "ntp",
- "openssh-clients",
- "rsync",
- "tcpdump",
- "telnet",
- "traceroute",
- "wget"
- };
- cfserver::
- "cfserver_processes" slist => { "cf-monitord", "cf-serverd" };
- classes:
- "cfserver" expression => strcmp("$(sys.fqhost)","cf0.xxx.xxx");
- commands:
- cfserver::
- "$(sys.workdir)/bin/$(cfserver_processes)"
- ifvarclass => canonify("start_$(cfserver_processes)");
- files:
- # Cleanup tmp
- "/tmp"
- delete => tidy,
- file_select => days_old("7"),
- depth_search => recurse("inf");
- # Copy /etc/motd
- "/etc/motd"
- perms => usystem("0644"),
- copy_from => umycopy("$(g.masterfiles)/etc/motd");
- # Copy /etc/resolv.conf
- "/etc/resolv.conf"
- perms => usystem("0644"),
- copy_from => umycopy("$(g.masterfiles)/etc/resolv.conf");
- # Copy /etc/sysconfig/autofsck
- "/etc/sysconfig/autofsck"
- perms => usystem("0644"),
- copy_from => umycopy("$(g.masterfiles)/etc/sysconfig/autofsck");
- # Copy /etc/xinetd.d/check_mk
- "/etc/xinetd.d/check_mk"
- perms => usystem("0644"),
- copy_from => umycopy("$(g.masterfiles)/etc/xinetd.d/check_mk");
- # Copy SSH Keys
- "/root/.ssh/."
- create => "true",
- perms => usystem("0700");
- "/root/.ssh/authorized_keys"
- create => "true",
- perms => usystem("0600"),
- edit_line => authorized_keys;
- # Edit /etc/sysconfig/network
- "/etc/sysconfig/network"
- perms => usystem("0644"),
- edit_line => etc_sysconfig_network;
- # Uncomment this to perform a change-detection scan
- # "/usr"
- # changes => lay_trip_wire,
- # depth_search => recurse("inf"),
- # action => measure;
- methods:
- "yum_config"
- usebundle => "yum_config";
- "manage_users"
- usebundle => "manage_users";
- "sshd_config"
- usebundle => "sshd_config";
- "vmware_tools"
- usebundle => "vmware_tools";
- packages:
- "$(standard_packages)"
- package_method => generic,
- package_policy => "add";
- "$(blacklisted_packages)"
- package_method => generic,
- package_policy => "delete";
- processes:
- cfserver::
- "$(cfserver_processes)"
- restart_class => canonify("start_$(cfserver_processes)");
- }
- body action measure
- {
- measurement_class => "Detect Changes in /usr";
- ifelapsed => "240"; # 4 hours
- expireafter => "240"; # 4 hours
- }
- bundle agent garbage_collection
- {
- files:
- # Cleanup outputs
- "$(sys.workdir)/outputs"
- delete => tidy,
- file_select => days_old("3"),
- depth_search => recurse("inf");
- }
- bundle agent manage_users
- {
- vars:
- "group[ryan]" string => "ryan::500:";
- "group[root]" string => "root:x:0:root";
- "shadow[ryan]" string => "ryan:$1$AAAAAAAAAAAAAAAAAAAAAAAACLQL3FO0:15183::::::";
- "shadow[root]" string => "root:$1$BBBBBBBBBBBBBBBBBBBBBBBB1IX7tZW.:15183::::::";
- "user[ryan]" string => "ryan:x:500:500::/home/ryan:/bin/bash";
- "user[root]" string => "root:x:0:0:root:/root:/bin/bash";
- "users" slist => getindices("user");
- files:
- # Add Users
- "/etc/passwd"
- edit_line => append_users_starting("manage_users.user");
- # Add Groups
- "/etc/group"
- edit_line => append_groups_starting("manage_users.group");
- # Set Passwords
- "/etc/shadow"
- edit_line => set_passwords("manage_users.shadow", "/etc/shadow");
- # Create Home Directories
- "/home/$(users)/."
- create => "true",
- perms => mog("755", "$(users)", "$(users)");
- }
- bundle agent sshd_config
- {
- vars:
- "sshd[ClientAliveInterval]" string => "1800";
- "sshd[ClientAliveCountMax]" string => "0";
- "sshd[IgnoreRhosts]" string => "yes";
- "sshd[HostbasedAuthentication]" string => "no";
- "sshd[PermitEmptyPasswords]" string => "no";
- "sshd[PermitRootLogin]" string => "without-password";
- "sshd[Protocol]" string => "2";
- commands:
- restart_sshd::
- "/etc/init.d/sshd restart";
- files:
- "/etc/ssh/sshd_config"
- classes => if_repaired("restart_sshd"),
- edit_line => set_keyword_values("sshd_config.sshd"),
- perms => usystem("0600");
- packages:
- "openssh-server"
- package_method => generic,
- package_policy => "add";
- processes:
- "/usr/sbin/sshd"
- restart_class => "restart_sshd";
- }
- bundle agent vmware_tools
- {
- vars:
- "mac" string => execresult("/sbin/ifconfig eth0 | /bin/grep -E -o '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'", "useshell");
- classes:
- "vm" expression => regcmp("^00:50:.*", "$(mac)");
- packages:
- vm::
- "vmware-tools"
- package_method => generic,
- package_policy => "add";
- # reports:
- # vm::
- # "This machine is a VM.";
- }
- bundle agent yum_config
- {
- classes:
- "rhel5"
- expression => regline("^CentOS Linux release 5.*", "/etc/redhat-release");
- "rhel6"
- expression => regline("^CentOS Linux release 6.*", "/etc/redhat-release");
- files:
- rhel5::
- "/etc/yum.repos.d/cobbler-config.repo"
- perms => usystem("0644"),
- copy_from => umycopy("$(g.masterfiles)/etc/yum.repos.d/cobbler-config.repo.rhel5");
- rhel6::
- "/etc/yum.repos.d/cobbler-config.repo"
- perms => usystem("0644"),
- copy_from => umycopy("$(g.masterfiles)/etc/yum.repos.d/cobbler-config.repo.rhel6");
- }
- bundle edit_line authorized_keys
- {
- insert_lines:
- "ssh-rsa CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC== [email protected]";
- }
- bundle edit_line etc_sysconfig_network
- {
- insert_lines:
- "NOZEROCONF=yes";
- "USERCTL=no";
- }
- bundle edit_line set_keyword_values(v)
- {
- vars:
- "index" slist => getindices("$(v)");
- # Be careful if the index string contains funny chars
- "cindex[$(index)]" string => canonify("$(index)");
- field_edits:
- # match a line starting like "keyword value"
- "$(index)\s* .*"
- edit_field => col(" ", "2", "$($(v)[$(index)])", "set"),
- classes => if_ok("not_$(cindex[$(index)])");
- insert_lines:
- "$(index) $($(v)[$(index)])"
- ifvarclass => "!not_$(cindex[$(index)])";
- }
- bundle edit_line set_passwords(v,f)
- {
- vars:
- "index" slist => getindices("$(v)");
- classes:
- "correct" expression => regline("^$($(v)[$(index)])", "$(f)");
- delete_lines:
- !correct::
- "^$(index):.*";
- insert_lines:
- "$($(v)[$(index)])";
- }
- bundle server access_rules
- {
- access:
- "${g.masterfiles}"
- admit => {
- "0.0.0.0/0"
- };
- }
- # promises.cf
- body common control {
- bundlesequence => {
- "update",
- "garbage_collection",
- "main"
- };
- inputs => {
- "update.cf",
- "site.cf",
- "cfengine_stdlib.cf"
- };
- }
- body executor control
- {
- exec_command => "$(sys.workdir)/bin/cf-agent -f failsafe.cf && $(sys.workdir)/bin/cf-agent";
- executorfacility => "LOG_DAEMON";
- mailmaxlines => "100";
- mailto => "[email protected]";
- smtpserver => "mail.xxx.xxx";
- splaytime => "1";
- }
- body monitor control
- {
- forgetrate => "0.7";
- }
- body reporter control
- {
- reports => { "performance", "last_seen", "monitor_history" };
- build_directory => "/tmp/nerves";
- report_output => "html";
- }
- body runagent control
- {
- hosts => {
- "127.0.0.1"
- };
- }
- body server control
- {
- allowconnects => { "0.0.0.0/0" };
- allowallconnects => { "0.0.0.0/0" };
- allowusers => { "root" };
- cfruncommand => "$(sys.workdir)/bin/cf-agent";
- logallconnections => "true";
- maxconnections => "10";
- skipverify => { "0.0.0.0/0" };
- trustkeysfrom => { "0.0.0.0/0" };
- }
- # update.cf
- bundle agent update
- {
- vars:
- "inputs" string => "$(g.masterfiles)/var/cfengine/inputs";
- files:
- # Alter permissions
- "/var/cfengine/."
- create => "true",
- perms => usystem("0700");
- # Alter permissions
- "/var/cfengine/bin/."
- create => "true",
- perms => usystem("0700");
- # Alter permissions
- "/var/cfengine/ppkeys/."
- create => "true",
- perms => usystem("0700");
- # Copy /var/cfengine/inputs
- "/var/cfengine/inputs"
- copy_from => umycopy("$(inputs)"),
- depth_search => urecurse("inf"),
- file_select => cf_files,
- perms => usystem("0600");
- }
- body copy_from umycopy(from)
- {
- source => "$(from)";
- servers => { "$(g.phost)" };
- compare => "digest";
- verify => "true";
- purge => "true";
- }
- body depth_search urecurse(d)
- {
- depth => "$(d)";
- exclude_dirs => { "\.svn" };
- }
- body file_select cf_files
- {
- leaf_name => { "\.cf$" };
- file_result => "leaf_name";
- }
- body perms usystem(p)
- {
- groups => { "root" };
- mode => "$(p)";
- owners => { "root" };
- }
Advertisement
Add Comment
Please, Sign In to add comment