Thanks to visit codestin.com
Credit goes to github.com

Skip to content

aix_lvg does not cleanly handle incorrect PP sizes and fails with 'OK' #58522

@d-little

Description

@d-little
SUMMARY

aix_lvg (aix_lvg.py) does not cleanly handle incorrect PP sizes. When the Parameter pp_size is set to an int value that is not valid for AIX the Task returns OK, but the command has actually failed.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

aix_lvg

ANSIBLE VERSION
ansible 2.8.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Apr  9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
CONFIGURATION
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -o ForwardAgent=no
COMMAND_WARNINGS(/etc/ansible/ansible.cfg) = True
DEFAULT_BECOME(/etc/ansible/ansible.cfg) = True
DEFAULT_FORCE_HANDLERS(/etc/ansible/ansible.cfg) = True
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 50
DEFAULT_MANAGED_STR(/etc/ansible/ansible.cfg) = This file is managed by ansible - local changes will be lost! - Last Updated {{ now(fmt='%Y/%m/%d - %H:%M:%S %z(%Z)') }}
DEFAULT_REMOTE_USER(/etc/ansible/ansible.cfg) = root
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles/internal', u'/etc/ansible/roles/external']
DEFAULT_TRANSPORT(/etc/ansible/ansible.cfg) = ssh
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = True
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = True
SYSTEM_WARNINGS(/etc/ansible/ansible.cfg) = True
OS / ENVIRONMENT

Target: AIX 7.2 LPAR

STEPS TO REPRODUCE

Set pp_size variable to any int that is not a valid pp size in AIX.

---
- name: "Test AIX LVM Stuff"
  hosts: all
  become: yes
  tasks:
  - name: manage_aix_lvm | creating new AIX volume group(s)
    # https://docs.ansible.com/ansible/latest/modules/aix_lvg_module.html#aix-lvg-module
    aix_lvg:
      force: "no"
      pp_size: "{{ item }}"
      pvs: "hdisk4"
      vg: "vg_exp1"
      state: present
    become: true
    with_items:
        - "-32"
        - 0
        - 129
        - "INVALID"
EXPECTED RESULTS

Using an invalid pp_size should be caught by the module itself and if for some reason it does pass it should not return 'OK' if it fails.

Expect that if pp_size is not valid, command should either not pass checks OR command should report Failure. With the above items list, I would expect this task to fail for ALL items in said list. It only fails with the "INVALID" string (cannot convert str to int)

Valid PP sizes are: any power of 2 per manual entry:

-s Size:  Sets the number of megabytes in each physical partition, where the Size variable is expressed in units of megabytes from 1 (1 MB) through 131072 (128 GB). The Size variable must be equal to a power of 2 (example 1, 2, 4, 8). The default value for 32 and 128 PV volume groups will be the lowest value to remain within the limitation of 1016 physical partitions per PV. The default value for scalable volume groups will be the lowest value to accommodate 2040 physical partitions per PV.```



##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->
The Ansible task does not fail and returns OK, but VG will not be created either. 

<!--- Paste verbatim command output between quotes -->
```paste below
ok: [TARGETHOST] => (item=-32) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "pp_size": -32,
            "pvs": [
                "hdisk4"
            ],
            "state": "present",
            "vg": "vg_exp1",
            "vg_type": "normal"
        }
    },
    "item": "-32",
    "msg": "Creating volume group 'vg_exp1' failed.",
    "state": "present"
}
ok: [TARGETHOST] => (item=0) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "pp_size": 0,
            "pvs": [
                "hdisk4"
            ],
            "state": "present",
            "vg": "vg_exp1",
            "vg_type": "normal"
        }
    },
    "item": 0,
    "msg": "Creating volume group 'vg_exp1' failed.",
    "state": "present"
}
ok: [TARGETHOST] => (item=129) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "pp_size": 129,
            "pvs": [
                "hdisk4"
            ],
            "state": "present",
            "vg": "vg_exp1",
            "vg_type": "normal"
        }
    },
    "item": 129,
    "msg": "Creating volume group 'vg_exp1' failed.",
    "state": "present"
}

failed: [TARGETHOST] (item=INVALID) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "pp_size": "INVALID",
            "pvs": [
                "hdisk4"
            ],
            "state": "present",
            "vg": "vg_exp1",
            "vg_type": "normal"
        }
    },
    "item": "INVALID",
    "msg": "argument pp_size is of type <type 'str'> and we were unable to convert to int: <type 'str'> cannot be converted to an int"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.8This issue/PR affects Ansible v2.8aixAIX communitybot_closedbugThis issue/PR relates to a bug.collectionRelated to Ansible Collections workcollection:community.generalhas_prThis issue has an associated PR.moduleThis issue/PR relates to a module.needs_collection_redirecthttps://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.mdsupport:communityThis issue/PR relates to code supported by the Ansible community.systemSystem category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions