I've got a scenario where I'll need to run a cfengine script as
various users, and then do different actions based on the user name.
(No, no, can't use root; that is verboten by Powers That Be...)
For instance... I have users pgonedatabaseuser,
pganotherdatabaseuser, pgyetanotherdatabaseuser.
I can write a nice tidy tidy section thus:
tidy:
pgonedatabaseuser.onedatabase::
/path/to/onedatabase
pattern=pg_*.log
age=$(pglogage)
pganotherdatabaseuser.anotherdatabase::
/path/to/anotherdatabase
pattern=pg_*.log
age=$(pglogage)
pgyetanotherdatabaseuser.yetanotherdatabase::
/path/to/yetanotherdatabase
pattern=pg_*.log
age=$(pglogage)
The trouble, at this point, is creating the
pgonedatabaseuser/pganotherdatabaseuser/pgyetanotherdatabaseuser
groups.
The best guess is something like:
control:
tempusername = ( ExecResult(/usr/bin/whoami) )
groups:
pgonedatabaseuser = ( StrCmp(${tempusername}, "pgonedatabaseuser"))
pganotherdatabaseuser = ( StrCmp(${tempusername},
"pganotherdatabaseuser"))
pgyetanotherdatabaseuser = ( StrCmp(${tempusername},
"pgyetanotherdatabaseuser"))
But apparently the groups are defined before tempusername gets defined.
There has got to be some better way that I'm not thinking of...