---
- hosts: ome
  connection: local
  name: Dell OpenManage Ansible User service.
  gather_facts: False

  collections:
    - dellemc.openmanage

  tasks:
  - name: create new user.
    ome_user:
        hostname: "{{hostname}}"
        username: "{{username}}"
        password: "{{password}}"
        attributes:
            UserName: "user1"
            Password: "UserPassword"
            RoleId: "10"
            Enabled: True
        
  - name: create user with all parameters
    ome_user:
        hostname: "{{hostname}}"
        username: "{{username}}"
        password: "{{password}}"
        state: "present"
        attributes:
            UserName: "user2"
            Description: "user2 description"
            Password: "UserPassword"
            RoleId: "10"
            Enabled: True
            DirectoryServiceId: 0
            UserTypeId: 1
            Locked: False
            Name: "user2"

  - name: modify existing user
    ome_user:
        hostname: "{{hostname}}"
        username: "{{username}}"
        password: "{{password}}"
        state: "present"
        attributes:
            UserName: "user3"
            RoleId: "10"
            Enabled: True
            Description: "Modify user Description"

  - name: delete existing user using id.
    ome_user:
        hostname:  "{{hostname}}"
        username: "{{username}}"
        password: "{{password}}"
        state: "absent"
        user_id: 61874
        
  - name: delete existing user using name.
    ome_user:
        hostname:  "{{hostname}}"
        username: "{{username}}"
        password: "{{password}}"
        state: "absent"
        name: "name"