Add user to "administrators" group or "administrateurs" group

Hello,

I would like to create a playbook that adds a user to the administrators group. This action is simple and is an example. But my problem is that I have servers in FR and the group is not administrators but administrators.

I saw that you could make conditions in the playbooks but I do not know how to test if I am on an OS FR or US.

Could you advise me?

Thank you beforehand.

Regards

I suggest you run the ‘setup’ module against your hosts, and use one of the facts to find out if the machine is FS or US.

For windows hosts, ansible_facts.ansible_env.USERNAME might be enough. If that isn’t enough, on windows hosts you can use the Get-Culture cmdlet to find out which culture is current on your host. Something like this.

  • name: culture test
    hosts: 12,
    gather_facts: false
    tasks:

  • name: get culture
    win_shell: Get-Culture|select Name|convertto-json -depth 1
    register: culture_raw

  • name: debug culture_raw
    debug:
    var: culture_raw

  • name: set culture fact
    set_fact:
    culture: “{{culture_raw.stdout|from_json}}”

  • name: debug culture
    debug:
    var: culture

  • name: do things when culture is en-US
    debug:
    msg: Doing en-US things
    when: culture.Name == ‘en-US’

  • name: do things when culture is something else
    debug:
    msg: Doing non-en-US things
    when: culture.Name != ‘en-US’