-
-
Save anonymous/cec38bbc0dae1cbfce43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#body common control | |
#{ | |
# inputs => { "/var/cfengine/inputs/libraries/cfengine_stdlib.cf", "./ftiff-common.cf" }; | |
# bundlesequence => { "ftiff:backup" }; | |
# host_licenses_paid => "25"; | |
#} | |
body file control | |
{ | |
namespace => "ftiff"; | |
} | |
bundle agent backup | |
{ | |
vars: | |
# global variables | |
"file[apt_dir]" string => "/etc/apt/sources.list.d"; | |
"file[key_dir]" string => "/etc/apt/trusted.gpg.d"; | |
# r1soft Repository (Ubuntu) | |
"r1soft[repo][file]" string => "r1soft-stable.list"; | |
"r1soft[repo][repo_url]" string => "deb http://repo.r1soft.com/apt stable main"; | |
"repokey[key_file]" string => "r1soft.gpg"; | |
"repokey[url]" string => "http://repo.r1soft.com/r1soft.asc"; | |
# r1soft server | |
"r1soft[pkg]" string => "r1soft-cdp-enterprise-agent"; | |
"r1soft[server]" string => "http://va07.esl.lan:8080"; | |
"r1soft[server_filename]" string => "va07.esl.lan"; # should be hostname only | |
"r1soft[process]" string => "r1soft/bin/cdp"; | |
"r1soft[service]" string => "cdp-agent"; | |
methods: | |
"add_repo" usebundle => ftiff:add_repo("$(file[apt_dir])/$(r1soft[repo][file])", "$(r1soft[repo][repo_url])"); | |
"add_repokey" usebundle => ftiff:add_repokey("ftiff:backup.repokey"); | |
"install_pkg" usebundle => ftiff:install_pkg("$(ftiff:backup.r1soft[pkg])"); | |
"get_hcp_module" usebundle => ftiff:get_hcp_module; | |
"check_process" usebundle => ftiff:check_process_cdp; | |
"add_server_key" usebundle => ftiff:r1soft_add_server_key("$(r1soft[server])", "$(r1soft[server_filename])"); | |
} | |
bundle agent get_hcp_module | |
{ | |
vars: | |
"uname_r" string => execresult("/bin/uname -r", "noshell"); | |
"lsmod" string => execresult("/bin/lsmod", "noshell"); | |
methods: | |
relaunch_cdp_agent:: | |
"check_process" usebundle => ftiff:service("$(ftiff:backup.r1soft[service])", "$(ftiff:backup.r1soft[process])", "restart"); | |
classes: | |
"hcp_module_present" | |
expression => fileexists("/lib/modules/r1soft/hcpdriver-cki-$(uname_r).ko"); | |
"hcp_module_loaded" | |
expression => regcmp(".*hcpdriver.*", "$(lsmod)"); | |
commands: | |
!hcp_module_present:: | |
"/usr/bin/r1soft-setup --get-module --silent" | |
comment => "Building hcp module", | |
classes => default:if_repaired("relaunch_cdp_agent"); | |
} | |
bundle agent check_process_cdp | |
{ | |
services: | |
"$(ftiff:backup.r1soft[service])" | |
service_policy => "start", | |
service_method => ftiff:cdp_agent; | |
} | |
body service_method cdp_agent | |
{ | |
service_bundle => ftiff:service("$(ftiff:backup.r1soft[service])", "$(ftiff:backup.r1soft[process])", "start"); | |
service_autostart_policy => "boot_time"; | |
} | |
bundle agent r1soft_add_server_key(url, filename) | |
{ | |
methods: | |
relaunch_cdp_agent:: | |
"check_process" usebundle => ftiff:service("$(ftiff:backup.r1soft[service])", "$(ftiff:backup.r1soft[process])", "restart"); | |
classes: | |
"server_key_present" | |
expression => fileexists("/usr/sbin/r1soft/conf/server.allow/$(filename)"); | |
commands: | |
!server_key_present:: | |
"/usr/bin/r1soft-setup --get-key $(url)" | |
comment => "Get server key.", | |
classes => default:if_repaired("relaunch_cdp_agent"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment