thierry thunot <tth...@gmail.com> writes:
I am facing a problem I am trying to filter my users and to establish a list of users whose UID is greater than 999.
i used getusers but I feel like the function's uid filter doesn't apply…. i tried this solution : "allusers" slist => getusers("","0"); to have uid 0 but there is no result
or "allusers" slist => getusers("","[1-9]{1,3}"); or have you got solution to extract all users whith UID greater than 999???
I think the documentation isn't very clear about it. The list is a string, specifically a comma separated string of uids to filter.
You can use expandrange() and join() to generate a comma separated string of ids from 0 to 999 being used as a filter:
bundle agent __main__ { vars: "users" slist => getusers( "", ""); "users_id_gt_999" slist => getusers( "", join( ",", expandrange( "[0-999]", 1 ) ) ); }
[root@hub masterfiles]# cf-agent -KIf ./example.cf --show-evaluated-vars=default:main\\. Variable name Variable value Meta tags Comment default:main.users {"root","bin","daemon","adm","lp","sync","shutdown","halt","mail","operator","games","ftp","nobody","systemd-network","dbus","polkitd","rpc","tss","rpcuser","nfsnobody","sshd","postfix","chrony","vagrant","cfapache","cfpostgres"} source=promise default:main.users_id_gt_999 {"nfsnobody","vagrant"} source=promise
– Nick Anderson | Doer of Things | (+1) 785-550-1767 | https://northern.tech
Great, glad that you found it helpful.
I went ahead and updated the docs.
https://docs.cfengine.com/docs/3.21/reference-functions-getusers.html#top
And, hopefully my change to make our automatic arguments rendering for
functions will be accepted so that more rich descriptions from
cf-promises --syntax-description=json of each
argument will be included as well.
https://tracker.mender.io/browse/CFE-4128