layout | title | published |
---|---|---|
default |
this |
true |
The context this
is used to access information about promises during
their execution. It is context dependent and not universally meaningful
or available, but provides a context for variables where one is needed
(such as when passing the value of a list variable into a parameterized
edit_line
promise from a files
promise).
bundle agent resolver(s,n)
{
files:
"$(sys.resolv)"
create => "true",
edit_line => doresolv("@(this.s)","@(this.n)"),
edit_defaults => reconstruct;
}
Note that every unqualified variable is automatically considered to be
in context this
, so that a reference to the variable $(foo)
is
identical to referencing $(this.foo)
. You are strongly encouraged to
not take advantage of this behavior, but simply to be aware that if
you attempt to declare a variable name with one of the following special
reserved names, CFEngine will issue a warning (and you can reference
your variable by qualifying it with the bundle name in which it is
declared).
This variable contains the current bundle name.
This variable points to the promise handle of the currently handled promise; it is useful for referring to the intention in log messages.
This variable contains the current namespace name.
This variable reveals the name of the file in which the current promise is defined.
This variable contains the directory name of the file in which the current promise is defined.
This variable reveals the line number in the file at which it is used. It is useful to differentiate otherwise identical reports promises.
The special variable $(this.promiser)
is used to refer to the current
value of the promiser itself.
In files
promises, where it is practical to use patterns or depth_search
to match multiple objects, the variable refers to the file that is currently
making the promise. However, the variable can only be used in selected
attributes:
transformer
edit_template
- [
source
][files#source] incopy_from
exec_program
infile_select
- class names in [
body classes
][Promise types#classes] - logging attributes in [
body action
][Promise types#action] - promised service name in
service_method
For example:
bundle agent find666
{
files:
"/home"
file_select => world_writeable,
transformer => "/bin/echo DETECTED $(this.promiser)",
depth_search => recurse("inf");
"/etc/.*"
file_select => world_writeable,
transformer => "/bin/echo DETECTED $(this.promiser)";
}
body file_select world_writeable
{
search_mode => { "o+w" };
file_result => "mode";
}
This variable refers to the uid
(user ID) of the user running the cf-agent
program.
Note: This variable is reported by the platform dependent getuid
function,
and is always an integer.
This variable refers to the gid
(group ID) of the user running the cf-agent
program.
Note: This variable is reported by the platform dependent getgid
function,
and is always an integer.
This variable refers to the pid
(process ID) of the cf-agent
program.
Note: This variable is reported by the platform dependent getpid
function,
and is always an integer.
This variable refers to the ppid
(parent process ID) of the cf-agent
program.
Note: This variable is reported by the platform dependent getpid
function,
and is always an integer. On the Windows platform it's always 0.
In a service_method
used by a services
type promise, this variable is set to
the value of the service_policy
promise attribute . For example:
bundle agent example
{
services:
"www"
service_policy => "start";
service_method => non_standard_services;
}
body service_method non_standard_services
{
service_bundle => non_standard_services( $(this.service_policy) );
}
This is typically used in the adaptations for custom services bundles in the service methods.
See also:
Services Bundles and Bodies
in theMasterfiles Policy Framework standard library
From version 3.3.0 on, this variable is reserved. It is used by
functions like maplist()
to represent the current object in a
transformation map.