I need to make edits to HKEY_CURRENT_USER of a different user then the ansible_user.
How do I do that?
Any edits I make with win_regmerge are made to the ansible_user’s registry.
I tried become_method: runas with become_user: but that throws a warning and error.
[WARNING]: The Windows ‘runas’ become method is experimental, and may change significantly in future Ansible releases.
FAILED! => {“failed”: true, “msg”: “The ‘runas’ become method requires a password (specify with the ‘-K’ CLI arg or the ‘ansible_become_password’ variable)”}
I come from a linux/unix background so I thought runas would be like sudo would let me run the command as the become_user but I guess runas is a little different.
Windows unfortunately doesn’t have the concept of sudo like unix so to be able to run a process as another user you need to set the password as well as the username. Going by the error message you need to set ‘ansible_become_password’ to the password of the account you are wanting to run as. I haven’t played around with runas unfortunately so I can’t give you any more info.
Another option if you really want to go the route is using the ‘HKEY_USERS’ key. The entry for ‘HKEY_CURRENT_USER’ in ‘HKEY_USERS’ is located in this key under the SID (S-----*). So using the ‘user’ account as an example I can use this command to get the SID of the Administrator account