I want to list a directory content and use the result somewhere else:
bundle agent test
{
commands:
"ls /tmp/test/";
reports:
ubuntu::
"print output here for example";
# or add it to a variable which is how I really want to use it.
}
See https://cfengine.com/manuals/cf3-solutions#Execresult-example
As of version 3.3.0, you can use the lsdir() function instead.
read more : https://cfengine.com/manuals/cf3-Reference#Function-lsdir