I’m starting with Ansible. I would like to know in a playbook how to test if the windows computer is in version FR or US. Following the test, I would add account users to the local “Administrators” or “Administrateurs” group.
By default:
name: Add a user
Hosts: windows_tst
Gather_facts: false
tasks:
One thing you can do is use the win_region module https://docs.ansible.com/ansible/win_region_module.html to change the region of your hosts to a common value. If this isn’t what you can do, you can also run an adhoc command to determine the group name based on the SID. Give the below tasks a shot and see if it returns what you are looking for.
name: get group name from sid
win_command: powershell.exe “((New-Object System.Security.Principal.SecurityIdentifier(‘S-1-5-32-544’)).Translate([System.Security.Principal.NTAccount]).Value -split ‘\’)[1]”
register: admin_group
debug:
var: admin_group.stdout_lines[0]
It looks up the group name based on the SID ‘S-1-5-32-544’ which is the default SID for the local administrators group and should be consistent across all Windows OS’.