ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
828 stars 1.53k forks source link

redfish_info: Accounts ListUsers shows empty account slots #6771

Closed mraineri closed 1 year ago

mraineri commented 1 year ago

Summary

Some Redfish services model empty account slots instead of using typical POST/DELETE semantics for adding/removing users. When invoking redfish.info Accounts ListUsers, it returns the empty account slots, which are not real user accounts. These empty accounts should be filtered from the response to not confuse users.

Issue Type

Bug Report

Component Name

redfish_info.py, redfish_utils.py

Ansible Version

$ ansible --version
ansible [core 2.13.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/rainem1/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /home/rainem1/.ansible/collections:/usr/share/ansible/collections
  executable location = /bin/ansible
  python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

Configuration

$ ansible-config dump --only-changed
# /usr/lib/python3/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 4.8.3  

# /usr/local/lib/python3.10/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.7.0  

# /home/rainem1/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 7.2.0

OS / Environment

Ubuntu

Steps to Reproduce

---
- hosts: all
  gather_facts: false
  vars:
    username: <REDACTED>
    password: <REDACTED>
    baseuri: <REDACTED>
    default_uri_timeout: 5
    default_uri_retries: 5
  tasks:
  - name: Get users
    community.general.redfish_info:
      category: Accounts
      command: ListUsers
      baseuri: "{{ baseuri }}"
      username: "{{ username }}"
      password: "{{ password }}"
    retries: "{{ default_uri_retries }}"
    register: redfish_results
  - debug:
      var: redfish_results

This needs to target a Redfish service that expose empty account slots like iDRAC on Dell PowerEdge servers.

Expected Results

Expected output

ok: [localhost] => {
    "redfish_results": {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/bin/python3"
        },
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "user": {
                "entries": [
                    {
                        "Enabled": true,
                        "Id": "2",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "Administrator",
                        "UserName": "root"
                    }
                ],
                "ret": true
            }
        }
    }
}

Actual Results

ok: [localhost] => {
    "redfish_results": {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/bin/python3"
        },
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "user": {
                "entries": [
                    {
                        "Enabled": false,
                        "Id": "1",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "None",
                        "UserName": ""
                    },
                    {
                        "Enabled": true,
                        "Id": "2",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "Administrator",
                        "UserName": "root"
                    },
                    {
                        "Enabled": false,
                        "Id": "3",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "4",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "5",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "6",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "7",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "8",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "9",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "10",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "11",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "12",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": true,
                        "Id": "13",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "14",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "15",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    },
                    {
                        "Enabled": false,
                        "Id": "16",
                        "Locked": false,
                        "Name": "User Account",
                        "RoleId": "ReadOnly",
                        "UserName": ""
                    }
                ],
                "ret": true
            }
        }
    }
}

Code of Conduct

ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 1 year ago

cc @TSKushal @bhavya06 @jyundt @rajeevkallur @renxulei @tomasg2012 @xmadsen click here for bot help

russoz commented 1 year ago

Change has been merged. Thanks @mraineri !