cf-execd
cf-execd is the scheduling daemon forcf-agent. It runscf-agent locally according to a schedule specified in policy code (executorcontrol body). After acf-agent run is completed,cf-execd gathers outputfromcf-agent, and may be configured to email the output to a specifiedaddress. It may also be configured tosplay (randomize)the execution schedule to prevent synchronizedcf-agent runs across anetwork.
cf-execd keeps the promises made incommon bundles, and is affected bycommon andexecutor control bodies.
Notes:
- This daemon reloads it's config when the SIGHUP signal is received.
cf-execdalways considers the classexecutorto be defined.
History:
- SIGHUP behavior added in 3.7.0
Command reference
--help , -h - Print the help message --debug , -d - Enable debugging output --verbose , -v - Output verbose information about the behaviour of cf-execd --dry-run , -n - All talk and no action mode - make no changes, only inform of promises not kept --version , -V - Output the version of the software --file , -f value - Specify an alternative input file than the default. This option is overridden by FILE if supplied as argument. --define , -D value - Define a list of comma separated classes to be defined at the start of execution --negate , -N value - Define a list of comma separated classes to be undefined at the start of execution --no-lock , -K - Ignore locking constraints during execution (ifelapsed/expireafter) if "too soon" to run --inform , -I - Print basic information about changes made to the system, i.e. promises repaired --diagnostic , -x - Activate internal diagnostics (developers only) --log-level , -g value - Specify how detailed logs should be. Possible values: 'error', 'warning', 'notice', 'info', 'verbose', 'debug' --no-fork , -F - Run as a foreground processes (do not fork) --once , -O - Run once and then exit (implies no-fork) --no-winsrv , -W - Do not run as a service on windows - use this when running from a command shell (CFEngine Nova only) --ld-library-path, -L value - Set the internal value of LD_LIBRARY_PATH for child processes --color , -C value - Enable colorized output. Possible values: 'always', 'auto', 'never'. If option is used, the default value is 'auto' --timestamp , -l - Log timestamps on each line of log output --ignore-preferred-augments - Ignore def_preferred.json file in favor of def.json --skip-db-check value - Do not run database integrity checks and repairs at startup --with-runagent-socket value - Specify the directory for the socket for runagent requests or 'no' to disable the socketControl promises
These body settings determine the behavior ofcf-execd,including schedulingtimes and output capture toWORKDIR/outputs and relay via email.
bodyexecutorcontrol{splaytime=>"5";mailto=>"cfengine@example.org";mailfrom=>"cfengine@$(host).example.org";smtpserver=>"localhost";schedule=>{"Min00","Min30"}}agent_expireafter
Description: Maximum agent runtime (in minutes)
Sets a maximum time on any run of the command inexec_command. Ifno data is received from the pipe opened to the process createdwithexec_command after the time has elapsed, the process getskilled.
Note that if you have long-running jobs, they may get killed withthis setting. Therefore, you should ensure it is higher than anyrun ofcf-agent that you want to leave alone. Alternatively, youcan make your jobs output something to STDOUT at least as often asthis threshold. This will reset the timer.
Type:int
Allowed input range:0,10080
Default value: 120
Example:
bodyexecutorcontrol{agent_expireafter=>"120";}Notes:The setting will effectively allow you to set a threshold on thenumber of simultaneous agents that are running. For example, if youset it to120 and you are using a 5-minute agent schedule, amaximum of 120 / 5 = 24 agents should be enforced.
See also:body action expireafter,body contain exec_timeout,body agent control expireafter
executorfacility
Description: Menu option for syslog facility level
Type: (menu option)
Allowed input range:
LOG_USERLOG_DAEMONLOG_LOCAL0LOG_LOCAL1LOG_LOCAL2LOG_LOCAL3LOG_LOCAL4LOG_LOCAL5LOG_LOCAL6LOG_LOCAL7See the syslog manual pages.
Default value:LOG_USER
Example:
bodyexecutorcontrol{executorfacility=>"LOG_USER";}exec_command
Description: The full path and command to the executable run bydefault (overridingbuiltin)
The command is run in a shell encapsulation so pipes and shellsymbols may be used if desired.
Type:string
Allowed input range:"?(/.*)
Note: Ifexec_command is not definedcf-agent will be executed with thefailsafe.cf policy.
Example:
exec_command => "$(sys.workdir)/bin/cf-agent -f update.cf && $(sys.workdir)/bin/cf-agent";mailfilter_exclude
Description: List ofanchored regular expressions that, ifmatched by a log entry, will cause that log entry to be excluded from agentexecution emails.
If no filter is set,cf-execd acts as if no log entry matches the excludepattern. If a log entry also matches a pattern inmailfilter_include, theexclude pattern takes precedence.
Type:slist
Allowed input range:.*
Note: Merely adding or removing a pattern that causes the number of matchinglog entries to change, does not guarantee that the next agent execution willgenerate an email from cf-execd. The actual output from cf-agent still has to bedifferent from the previous run for an email to be generated.
Example:
bodyexecutorcontrol{# Ignore agent execution emails about permission errors.mailfilter_exclude=>{".*Permission denied.*"};}History: Introduced in CFEngine 3.9.
mailfilter_include
Description: List ofanchored regular expressions that mustmatch a log entry in order for it to be included in agent execution emails.
If no filter is set,cf-execd acts as if every log entry matches the includepattern. If a log entry also matches a pattern inmailfilter_exclude, theexclude pattern takes precedence.
Type:slist
Allowed input range:.*
Note: Merely adding or removing a pattern that causes the number of matchinglog entries to change, does not guarantee that the next agent execution willgenerate an email from cf-execd. The actual output from cf-agent still has to bedifferent from the previous run for an email to be generated.
Example:
bodyexecutorcontrol{# Only include reports in agent execution emails.mailfilter_include=>{"R:.*"};}History: Introduced in CFEngine 3.9.
mailfrom
Description: Email-address CFEngine mail appears to come from
Type:string
Allowed input range:.*@.*
Example:
bodyexecutorcontrol{mailfrom=>"mrcfengine@example.org";}mailmaxlines
Description: Maximum number of lines of output to send by email
This limit prevents anomalously large outputs from clogging up a systemadministrator's mailbox. The output is truncated in the email report, but thecomplete original transcript is stored inWORKDIR/outputs/* where it can beviewed on demand. A reference to the appropriate file is given.
Type:int
Allowed input range:0,1000
Default value: 30
Example:
bodyexecutorcontrol{mailmaxlines=>"100";}mailsubject
Description: The subject in the mail sent by CFEngine.
The subject can contain system variables, like for example IP address orarchitecture.
Type:string
Allowed input range:.*
Example:
bodyexecutorcontrol{mailsubject=>"CFEngine report ($(sys.fqhost))";}mailto
Description: Email-address CFEngine mail is sent to
The address to whom email is sent if an smtp host is configured.
Type:string
Allowed input range:.*@.*
Example:
bodyexecutorcontrol{mailto=>"cfengine_alias@example.org";}schedule
Description: The class schedule used by cf-execd for activatingcf-agent
The list should contain class expressions comprised of classeswhich are visible to thecf-execd daemon. In principle, anydefined class expression will cause the daemon to wake up andschedule the execution of thecf-agent. In practice, the classeslisted in the list are usually date- and time-based.
The actual execution ofcf-agent may be delayed bysplaytime,and may be deferred by promise caching and the value ofifelapsed. Note also that the effectiveness of thesplayclassfunction may be affected by changing theschedule.
Type:slist
Allowed input range: (arbitrary string)
Default value:
schedule => { "Min00", "Min05", "Min10", "Min15", "Min20", "Min25", "Min30", "Min35", "Min40", "Min45", "Min50", "Min55" };Example:
bodyexecutorcontrol{schedule=>{"Min00","(Evening|Night).Min15","Min30","(Evening|Night).Min45"};}smtpserver
Description: Name or IP of a willing smtp server for sendingemail
This should point to a standard port 25 server without encryption. If you arerunning secured or encrypted email then you should run a mail relay onlocalhost and point this to localhost.
Type:string
Allowed input range:.*
Example:
bodyexecutorcontrol{smtpserver=>"smtp.example.org";}splaytime
Description: Time in minutes to splay this host based on its namehash
Whenever any class listed in theschedule attribute is present,cf-execd can schedule an execution ofcf-agent. The actualexecution will be delayed an integer number of seconds between0-splaytime minutes. The specific amount of delay for "this" hostis based on a hash of the hostname. Thus a collection of hosts willall execute at different times, and surges in network traffic canbe avoided.
A general rule for scaling of small updates is to set the splay time toruninterval-1 minutes for up a few thousand hosts. For example, the defaultschedule executes once every 5 minutes, so the splay time should be set to nomore than 4 minutes. Thesplaytime should be set to a value less than thecf-execd scheduling interval, else multiple clients might contend for data.In other words,splaytime +cf-agent run time should be less than thescheduling interval.
Type:int
Allowed input range:0,99999999999
Default value: 0
The CFEngine default policy setssplaytime to 1.
Example:
bodyexecutorcontrol{splaytime=>"2";}See also: Thesplayclass() function for a task-specificmeans for setting splay times.
runagent_socket_allow_users
Description: Users who are allowed access the socket (STATEDIR/cf-execd.sockets/runagent.socket).
Type:slist
Allowed input range:.*
Default value: none
Notes:
- By default, in the Masterfiles Policy Framework,
cfapacheis allowed to access the socket on Enterprise Hubs.
Example:
bodyexecutorcontrol{runagent_socket_allow_users=>{"yoda","obi-wan"};}See also:cf-runagent
History:
- 3.18.0 Added
runagent_socket_allow_usersattribute
Sockets
cf-execd createsSTATEDIR/cf-execd.sockets/runagent.socket (/var/cfengine/state/cf-execd.sockets/runagent.socket).
Thebody executor control attributerunagent_socket_allow_users controls the list of users that should be allowed to access (**RW**) the socket via ACLs.
Notes:
- Unlike execution triggered with the
cf-runagentbinary, there is currently no capability to define additional options like defining additional classes, or the remote bundlesequence.
Example:
Write the name or IP into the socket to request unscheduled execution on that host:
echo 'host001' > /var/cfengine/state/cf-execd.sockets/cf-runagent.socketSee also:cf-runagent,runagent_socket_allow_users
History:
- 3.18.0 Added socket for triggering
cf-runagentby hostname or IP.
- Overview
- Getting started
- Reference
- Components
- Functions
- accessedbefore
- accumulated
- ago
- and
- basename
- bundlesmatching
- bundlestate
- callstack_callers
- callstack_promisers
- canonify
- canonifyuniquely
- cf_version_after
- cf_version_at
- cf_version_before
- cf_version_between
- cf_version_maximum
- cf_version_minimum
- changedbefore
- classesmatching
- classfiltercsv
- classify
- classmatch
- concat
- countclassesmatching
- countlinesmatching
- data_expand
- data_readstringarray
- data_readstringarrayidx
- data_regextract
- data_sysctlvalues
- datastate
- difference
- dirname
- diskfree
- escape
- eval
- every
- execresult
- execresult_as_data
- expandrange
- file_hash
- fileexists
- filesexist
- filesize
- filestat
- filter
- findfiles
- findfiles_up
- findprocesses
- format
- getclassmetatags
- getenv
- getfields
- getgid
- getindices
- getuid
- getuserinfo
- getusers
- getvalues
- getvariablemetatags
- grep
- groupexists
- hash
- hash_to_int
- hashmatch
- host2ip
- hostinnetgroup
- hostrange
- hostsseen
- hostswithclass
- hubknowledge
- ifelse
- int
- intersection
- ip2host
- iprange
- irange
- isdir
- isexecutable
- isgreaterthan
- isipinsubnet
- islessthan
- islink
- isnewerthan
- isplain
- isreadable
- isvariable
- join
- lastnode
- laterthan
- ldaparray
- ldaplist
- ldapvalue
- length
- lsdir
- makerule
- maparray
- mapdata
- maplist
- max
- mean
- mergedata
- min
- network_connections
- none
- not
- now
- nth
- on
- or
- packagesmatching
- packageupdatesmatching
- parseintarray
- parsejson
- parserealarray
- parsestringarray
- parsestringarrayidx
- parseyaml
- peerleader
- peerleaders
- peers
- processexists
- product
- randomint
- read_module_protocol
- readcsv
- readdata
- readenvfile
- readfile
- readintarray
- readintlist
- readjson
- readrealarray
- readreallist
- readstringarray
- readstringarrayidx
- readstringlist
- readtcp
- readyaml
- regarray
- regcmp
- regex_replace
- regextract
- registryvalue
- regldap
- regline
- reglist
- remoteclassesmatching
- remotescalar
- returnszero
- reverse
- rrange
- selectservers
- shuffle
- some
- sort
- splayclass
- splitstring
- storejson
- strcmp
- strftime
- string
- string_downcase
- string_head
- string_length
- string_mustache
- string_replace
- string_reverse
- string_split
- string_tail
- string_trim
- string_upcase
- sublist
- sum
- sysctlvalue
- translatepath
- type
- unique
- url_get
- usemodule
- userexists
- validdata
- validjson
- variablesmatching
- variablesmatching_as_data
- variance
- version_compare
- Language concepts
- Masterfiles Policy Framework
- promises.cf
- .no-distrib/
- update.cf
- standalone_self_upgrade.cf
- cfe_internal/
- cfe_internal/CFE_cfengine.cf
- cfe_internal/core/
- cfe_internal/core/watchdog
- cfe_internal/core/watchdog/watchdog.cf
- cfe_internal/enterprise/
- cfe_internal/enterprise/federation/
- cfe_internal/enterprise/federation/federation.cf
- cfe_internal/recommendations.cf
- cfe_internal/update/
- cfe_internal/update/cfe_internal_dc_workflow.cf
- cfe_internal/update/cfe_internal_update_from_repository.cf
- cfe_internal/update/lib.cf
- cfe_internal/update/systemd_units.cf
- cfe_internal/update/update_bins.cf
- cfe_internal/update/update_policy.cf
- cfe_internal/update/update_processes.cf
- controls/
- controls/cf_agent.cf
- controls/cf_execd.cf
- controls/cf_hub.cf
- controls/cf_monitord.cf
- controls/cf_runagent.cf
- controls/cf_serverd.cf
- controls/def.cf
- controls/def_inputs.cf
- controls/reports.cf
- controls/update_def.cf
- controls/update_def_inputs.cf
- inventory/
- inventory/any.cf
- inventory/debian.cf
- inventory/freebsd.cf
- inventory/generic.cf
- inventory/linux.cf
- inventory/lsb.cf
- inventory/macos.cf
- inventory/os.cf
- inventory/redhat.cf
- inventory/suse.cf
- inventory/windows.cf
- lib/
- lib/autorun.cf
- lib/bundles.cf
- lib/cfe_internal.cf
- lib/cfe_internal_hub.cf
- lib/cfengine_enterprise_hub_ha.cf
- lib/commands.cf
- lib/common.cf
- lib/databases.cf
- lib/edit_xml.cf
- lib/event.cf
- lib/examples.cf
- lib/feature.cf
- lib/files.cf
- lib/guest_environments.cf
- lib/monitor.cf
- lib/packages.cf
- lib/paths.cf
- lib/processes.cf
- lib/reports.cf
- lib/services.cf
- lib/stdlib.cf
- lib/storage.cf
- lib/testing.cf
- lib/users.cf
- lib/vcs.cf
- modules/
- modules/mustache/
- modules/packages/
- modules/packages/vendored/
- modules/promises/
- modules/promises/cfengine.py
- modules/promises/cfengine.sh
- services/
- services/autorun/
- services/main.cf
- Macros
- Promise types
- Special variables
- All promise and body types
- Release notes
- Web UI
- Settings
- Health
- Hosts
- Alerts and notifications
- Custom actions for alerts
- Enterprise reporting
- Federated reporting
- Measurements app
- Hub administration
- Decommissioning hosts
- Extending Mission Portal
- Extending query builder in Mission Portal
- Adjusting schedules
- Backup and restore
- Configure a custom LDAP port
- Custom LDAPs certificate
- Custom SSL certificate
- Enable plain http
- Lookup license info
- Policy deployment
- Public key distribution
- Re-installing Enterprise hub
- Regenerate self signed SSL certificate
- Reset administrative credentials
- Debugging Mission Portal
- License
- Examples and tutorials
- Example snippets
- General examples
- Administration examples
- Measuring examples
- Software administration examples
- Commands, scripts, and execution examples
- File and directory examples
- File template examples
- Interacting with directory services
- Database examples
- Network examples
- System security examples
- System information examples
- System administration examples
- System file examples
- Windows registry examples
- File permissions
- User management examples
- Common promise patterns
- Aborting execution
- Change detection
- Check filesystem space
- Copy single files
- Create files and directories
- Customize message of the day
- Distribute ssh keys
- Ensure a process is not running
- Ensure a service is enabled and running
- Find the MAC address
- Install packages
- Mount NFS filesystem
- Restart a process
- Set up name resolution with DNS
- Set up sudo
- Set up time management through NTP
- Updating from a central policy server
- Tutorials
- JSON and YAML support in CFEngine
- Installing CFEngine Enterprise agent
- Managing local users
- Managing network time protocol
- Managing processes and services
- Package management
- Writing CFEngine policy
- Distributing files from a central location
- File editing
- Reporting and remediation of security vulnerabilities
- Masterfiles Policy Framework upgrade
- Tags for variables, classes, and bundles
- Custom inventory
- Dashboard alerts
- Integrating alerts with PagerDuty
- Integrating alerts with ticketing systems
- Integrating with Sumo Logic
- Rendering files with Mustache templates
- Reporting
- File comparison
- High availability
- Writing and serving policy
- Example snippets
- Resources
- FAQ
- Why knowledge management?
- Requesting a CFEngine Enterprise License
- Uninstalling / reinstalling
- Agent output email
- Debugging slow queries
- Enterprise Report Filtering
- Enterprise report collection
- Enterprise reporting database
- How can I tell what classes and variables are defined?
- How do I find the public key for a given host
- How do I fix trust after an IP change?
- How do I fix undefined body errors?
- How do I integrate custom policy?
- How do I pass a data type variable?
- Manual execution
- Mustache templating
- Unable to log into Mission Portal
- Users
- What is promise locking?
- Why are remote agents not updating?
- Why are some files inside masterfiles not being updated/distributed?
- Why does CFEngine install into /var/cfengine instead of following the FHS?
- Bootstrapping
- Tuning PostgreSQL
- What did CFEngine do?
- External resources
- Additional topics
- Best practices
- FAQ
- API
- Enterprise API examples
- Enterprise API reference
- Actions API
- Build API
- CMDB API
- Changes REST API
- Federated reporting configuration API
- File changes API
- Health diagnostic API
- Host REST API
- Import & export API
- Import & export compliance report API
- Inventory API
- LDAP authentication API
- Personal groups API
- Query REST API
- SQL schema
- SSH keys API
- Shared groups API
- Status and settings REST API
- Two-factor authentication API
- Users and access-control REST API
- VCS settings API
- Web RBAC API