# Adding the Admin role to newly created VMWare local user (host)

**URL:** <https://forum.ansible.com/t/adding-the-admin-role-to-newly-created-vmware-local-user-host/6218>\
**Category:** Get Help\
**Tags:** vmware\
**Created:** [June 6, 2024, 1:16pm UTC](https://forum.ansible.com/t/adding-the-admin-role-to-newly-created-vmware-local-user-host/6218 "2024-06-06T13:16:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NRG](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@NRG](https://forum.ansible.com/u/NRG)\
**Post date:** [June 6, 2024, 1:16pm UTC](https://forum.ansible.com/t/adding-the-admin-role-to-newly-created-vmware-local-user-host/6218/1 "2024-06-06T13:16:24Z")

</div>

Good Day everyone,

First: I apologize if this thread if posted someplace else, I’ve looked but cannot find this particular issue…

I’m new to Ansible and configurations but I learn fairly quickly. I have been trying for hours to figure out which module and how to add the Administrator role to a newly created local user account on a VMWare host machine.

I’ve been able to figure out 90% of what I need so far, I just cannot figure out this piece.

This is what I have now…

```yaml
    - name: Add User Roles
      community.vmware.vmware_local_role_manager:
        hostname: "{{ esxi_host }}"
        username: "{{ esxi_user }}"
        password: "{{ esxi_password }}"
        validate_certs: false
        local_role_name: "Administrator"
        principal: "{{ item.new_username }}"
        state: present
      loop: "{{ users }}"
      delegate_to: localhost

```

Edit:  
This is the error I’m getting:

TASK [Add User Roles] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [10.10.10.176 → localhost] (item={‘new\_username’: ‘Armory’, ‘password’: ‘P@ssw0rd1!’, ‘description’: ‘Armory Staff’, ‘role’: ‘Admin’}) =\> {“ansible\_loop\_var”: “item”, “changed”: false, “item”: {“description”: “Armory Staff”, “new\_username”: “Armory”, “password”: “P@ssw0rd1!”, “role”: “Admin”}, “msg”: “Unsupported parameters for (community.vmware.vmware\_local\_role\_manager) module: principal. Supported parameters include: action, force\_remove, hostname, local\_privilege\_ids, local\_role\_name, password, port, proxy\_host, proxy\_port, state, username, validate\_certs (admin, pass, pwd, user).”}  
failed: [10.10.10.176 → localhost] (item={‘new\_username’: ‘Support’, ‘password’: ‘KJHC@!#!CAWlkjasc’, ‘description’: ‘Support Staff’, ‘role’: ‘Admin’}) =\> {“ansible\_loop\_var”: “item”, “changed”: false, “item”: {“description”: “Support Staff”, “new\_username”: “Support”, “password”: “KJHC@!#!CAWlkjasc”, “role”: “Admin”}, “msg”: “Unsupported parameters for (community.vmware.vmware\_local\_role\_manager) module: principal. Supported parameters include: action, force\_remove, hostname, local\_privilege\_ids, local\_role\_name, password, port, proxy\_host, proxy\_port, state, username, validate\_certs (admin, pass, pwd, user).”}

I’ve also tried with the community.vmware.vmware\_object\_role\_permission module… I just can’t seem to figure it out and when I search online, it pulls up EVERYTHING except what I’m looking for…

I just need a little help.

Thanks,  
Nate

---

<div class="post-metadata">

**Author:** ![Gnonthgol](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@Gnonthgol](https://forum.ansible.com/u/Gnonthgol)\
**Post date:** [June 8, 2024, 10:17am UTC](https://forum.ansible.com/t/adding-the-admin-role-to-newly-created-vmware-local-user-host/6218/2 "2024-06-08T10:17:37Z")

</div>

The error message is pretty clear. You are trying to set the parameter ‘principal’ but the vmware\_local\_role\_manager module does not have such a parameter. From the documentation it looks like you are looking for the ‘local\_privilege\_ids’ parameter instead. Or you are looking for the ’ vmware\_object\_role\_permission’ module which does have a principal parameter and looks to be more like what you are trying to do.

---

<div class="post-metadata">

**Author:** ![NRG](https://avatars.discourse-cdn.com/v4/letter/n/b487fb/32.png) [@NRG](https://forum.ansible.com/u/NRG)\
**Post date:** [June 9, 2024, 4:03am UTC](https://forum.ansible.com/t/adding-the-admin-role-to-newly-created-vmware-local-user-host/6218/3 "2024-06-09T04:03:06Z")

</div>

I appreciate the reply.

I didn’t realize that I had to assign a permission to a folder and was trying everything except folders… so now my playbook looks like this…

```yaml
    users:
      - new_username: adminstaff
        password: <password here>
        description: "Admin department Staff"
        role: "Admin"
      - new_username: support
        password: <password here>
        description: "Support Staff"
        role: "Admin"
      - new_username: deploy
        password: <password here>
        role: "ReadOnly"
        description: "deployment user account"

  tasks:
    - name: Create user accounts
      community.vmware.vmware_local_user_manager:
        hostname: "{{ esxi_host }}"
        username: "{{ esxi_user }}"
        password: "{{ esxi_password }}"
        validate_certs: false
        local_user_name: "{{ item.new_username }}"
        local_user_password: "{{ item.password }}"
        local_user_description: "{{ item.description }}"
        state: present
      loop: "{{ users }}"
      delegate_to: localhost

    - name: Add User Roles
      community.vmware.vmware_object_role_permission:
        hostname: "{{ esxi_host }}"
        username: "{{ esxi_user }}"
        password: "{{ esxi_password }}"
        validate_certs: false
        object_name: rootFolder
        role: "{{ item.role }}"
        principal: "{{ item.new_username }}"
        state: present
      loop: "{{ users }}"
      delegate_to: localhost

```

This method works and each user has been put in the admin/ReadOnly group respectfully.

Thanks, I appreciate your time.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 9, 2024, 4:03am UTC](https://forum.ansible.com/t/adding-the-admin-role-to-newly-created-vmware-local-user-host/6218/4 "2024-07-09T04:03:18Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
