How can I use Use Chef to set Environment Variables for different Windows Users?
I've tried using the Execute
block like so:
execute 'setx DUMMYENV' do
command 'setx DUMMYENV "THISISDUMMY"'
user "UserA"
end
However this requires a password and I don't want the password in plaintext in any of the recipes so this solution doesn't seem viable.
I've also thought about doing something with registry_key
like so:
registry_key 'HKEY_USERS\S-1-5-21-0123456789-012345678-...\Environment' do
values [{name: 'DUMMYENV', type: :string, data: '1'},
{name: 'ENVTEST', type: :string, data: 'TESTING'}
]
action :create
end
The only problem I have with this is I'm not sure if the SID for each of the User accounts I'm trying to modify will change between machines. I can probably find a solution to loop through the available HKEY_Users and parse out the ones I'm looking for however this seems tedious.
Another option that I've started to look into is windows_env
however I haven't gotten to test it much and I don't see a robust option to specify the user.
End goal is to set different environment variables for different users with Chef running as admin. Is there any easy way to do this with Chef?
Thanks in advance!