On Thu, 09 Jul 2015 06:35:40 -0400 Ted Zlatanov <
t...@lifelogs.com> wrote:
TZ> Together with `inputs`, the location of some system utilities, and
TZ> others, these too-early-for-policy settings would benefit from being
TZ> obtained from environment variables and also from a optional file like
TZ> K1=V1
TZ> K2=V2
TZ> or in JSON format. As long as the usual sys and const variables are
TZ> expanded, I feel this will be very user-friendly.
TZ> Another use for this is to add per-system classes instead of specifying
TZ> -Dx,y,z on every invocation.
TZ> This is fairly easy to implement and would resolve many policy-level
TZ> race issues.
The new def.json facility in 3.7 could be the simplest way to do this.
It currently has this content (as an example):
#+begin_src text
{
"classes":
{
"my_apache": [ "server1", "server2", "redhat.*" ],
"my_other_apache": [ "server[34]", "debian.*" ],
"my_filehost": [ "server3" ],
"my_gateway": [ "server3" ],
"my_yum_role": [ "redhat.*" ],
"my_redhat_role": [ "redhat.*" ],
"my_apt_role": [ "debian.*" ],
"my_debian_role": [ "debian.*" ],
"services_autorun": [ "any" ],
"cfengine_internal_disable_agent_email": [ "enterprise_edition" ]
"cfe_internal_core_watchdog_enabled": [ "any" ],
},
"inputs": [ "$(sys.libdir)/
bundles.cf" ],
"vars": {
"acl": [ ".*$(def.domain)", "$(sys.policy_hub)/16" ],
"domain": "mydomain-com",
"mailto": "people@mydomain-com",
"mailfrom": "me@mydomain-com",
"smtpserver": "smtp.mydomain-com",
"input_name_patterns": [ ".*\\.cf",".*\\.dat",".*\\.txt", ".*\\.conf", ".*\\.mustache",
".*\\.sh", ".*\\.pl", ".*\\.py", ".*\\.rb",
"cf_promises_release_id", ".*\\.json", ".*\\.yaml", ".*\\.js" ]
}
}
#+end_src
So, if agents load this in C instead of policy, what can they use here
on startup? All of the classes here could be evaluated after the hard
and persistent classes are loaded in the agent. Then they could be
evaluated again in policy to cover any soft classes.
The inputs can definitely be loaded before any policy is loaded and would
make it much easier to construct the inputs correctly.
Any variables in def.json/vars would go into the "def" variable scope,
so for instance the `acl` value of `def.domain` would resolve to the
`domain` right under it.
Loading def.json in C would also remove a pretty big chunk of policy
from the current masterfiles. It can be validated more carefully, as
well. Finally, using YAML would work as well (internally they both
produce JsonElements), if readability is a concern.
What do you think?
Ted