Teradata / stacki

Linux Cluster Builder - Bare Metal Red Hat & SUSE
http://www.stacki.org
Other
234 stars 74 forks source link

FEATURE: Ansible module for attribute info #840

Closed caladd closed 3 years ago

caladd commented 4 years ago

An Ansible module for returning attribute info for a given scope.

The module takes several optional parameters: scope for specifying the scope of the data to return. Valid choices are: global (default), appliance, os, environment, and host. name for requesting the data for a specific item in the scope. If name is not provided, then all data for that scope is returned. attr to specify attributes to return data about. Can be a shell syntax glob pattern. shadow to control if shadow attributes are returned in the data. Defaults to True.

The data returned is a list of attributes.

Example playbook:

---
- hosts: localhost
  tasks:
    - name: Get attributes for the backend appliance
      stacki_attribute_info:
        name: backend
        scope: appliance
      register: result

    - name: Appliance attribute output
      debug:
        var: result

    - name: Get the os.version attribute for backend-0-0
      stacki_attribute_info:
        name: backend-0-0
        scope: host
        attr: os.version
      register: result

    - name: Host backend-0-0 attribute output
      debug:
        var: result

Output of the debug commands, showing the structure of the data returned:

TASK [Appliance attribute output] ***************************************************************************************************************
ok: [localhost] => {
    "result": {
        "attributes": [
            {
                "appliance": "backend",
                "attr": "kickstartable",
                "scope": "appliance",
                "type": "var",
                "value": "True"
            },
            {
                "appliance": "backend",
                "attr": "managed",
                "scope": "appliance",
                "type": "var",
                "value": "True"
            },
            {
                "appliance": "backend",
                "attr": "node",
                "scope": "appliance",
                "type": "var",
                "value": "backend"
            }
        ],
        "changed": false,
        "failed": false
    }
}

TASK [Host backend-0-0 attribute output] ********************************************************************************************************
ok: [localhost] => {
    "result": {
        "attributes": [
            {
                "attr": "os.version",
                "host": "backend-0-0",
                "scope": "host",
                "type": "const",
                "value": "12.x"
            }
        ],
        "changed": false,
        "failed": false
    }
}
bsanders commented 3 years ago

Rebased and merged