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

Skip to content

Fix reported issues failing-ok and pp_size in module aix_lvg #58651

Closed
d-little wants to merge 5 commits intoansible:develfrom
d-little:aix_lvg_fixes
Closed

Fix reported issues failing-ok and pp_size in module aix_lvg #58651
d-little wants to merge 5 commits intoansible:develfrom
d-little:aix_lvg_fixes

Conversation

@d-little
Copy link
Contributor

@d-little d-little commented Jul 2, 2019

SUMMARY

Fixes two issues described in #58522:

  1. If VG fails to create, exist with fail_json instead of returning OK.
  2. Added checks to main() to confirm that supplied pp_size is a valid value before continuing.
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

aix_lvg

ADDITIONAL INFORMATION

See #58522 for full issue details.

Test output:

With test task:

---
- name: "Test AIX LVM Stuff"
  hosts: all
  become: yes
  tasks:
  - name: manage_aix_lvm | creating new AIX volume group(s)
      force: true
      pp_size: "{{ item }}"
      pvs: "hdisk4"
      vg: "vg_exp1"
      state: present
    become: true
    with_items:
        - "-32"
        - 0
        - 129
        - "INVALID"
        - 128

Before:- False OK's returned from invalid data and failed creations

ok: [TEST] => (item=-32)
ok: [TEST] => (item=0)
ok: [TEST] => (item=129)
failed: [TEST] (item=INVALID) => {"ansible_loop_var": "item", "changed": false, "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"}
ok: [TEST] => (item=256)


ok: [TEST] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "force": true,
            "pp_size": 2048,
            "pvs": [
                "hdisk4"
            ],
            "state": "present",
            "vg": "vg_exp1",
            "vg_type": "normal"
        }
    },
    "msg": "Creating volume group 'vg_exp1' failed.",
    "state": "present"
}


After:

failed: [TEST] (item=-32) => {"ansible_loop_var": "item", "changed": false, "item": "-32", "msg": "pp_size must be >0 and a multiple of 2 (supplied: '-32')."}
failed: [TEST] (item=0) => {"ansible_loop_var": "item", "changed": false, "item": 0, "msg": "pp_size must be >0 and a multiple of 2 (supplied: '0')."}
failed: [TEST] (item=129) => {"ansible_loop_var": "item", "changed": false, "item": 129, "msg": "pp_size must be >0 and a multiple of 2 (supplied: '129')."}
failed: [TEST] (item=INVALID) => {"ansible_loop_var": "item", "changed": false, "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"}
changed: [TEST] => (item=128)



fatal: [TEST]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "force": true,
            "pp_size": 2048,
            "pvs": [
                "hdisk4"
            ],
            "state": "present",
            "vg": "vg_expx1",
            "vg_type": "normal"
        }
    },
    "msg": "Failed to create volume group 'vg_expx1' using command '/usr/sbin/mkvg  -s 2048 -f -y vg_expx1 hdisk4'. Error message: 0516-1197 /usr/sbin/mkvg: The -s parameter for Size must be a power\n\tof 2 between 1 and 1024.\n0516-862 /usr/sbin/mkvg: Unable to create volume group.\n"
}


@d-little d-little marked this pull request as ready for review July 2, 2019 22:05
@d-little d-little changed the title aix_lvg fixes: #58522 aix_lvg fixes Jul 2, 2019
@d-little d-little changed the title aix_lvg fixes Fix reported issues failing-ok and pp_size in module aix_lvg Jul 2, 2019
@ansibot
Copy link
Contributor

ansibot commented Jul 2, 2019

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 aix AIX community bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. system System category labels Jul 2, 2019
@mator
Copy link
Contributor

mator commented Jul 3, 2019

@d-little , how do you run (command line) your playbook ? thanks.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jul 3, 2019
@d-little
Copy link
Contributor Author

d-little commented Jul 3, 2019

@mator , I've cleaned up that test playbook a tiny bit. just the one task for my testing purposes.

# ansible-playbook -i ~/test.ini ~/test_aix_lvg.yml
# cat ~/test_aix_lvg.yml
---
- name: Test AIX module aix_lvg
  hosts: TESTHOST
  become: true
  vars:
    hdisk: hdisk4
    vgname: vg_tstexp
  tasks:
    - name: "Test AIX LVM with Invalid PP Values"
      become: yes
      aix_lvg:
        force: true
        pp_size: "{{ item }}"
        pvs: "{{ hdisk }}"
        vg: "{{ vgname }}"
        state: present
      with_items:
        - "-32"
        - 0
        - 129
        - "INVALID"

Run with the updated module code:

# ansible-playbook -i ~/test.ini ~/test_aix_lvg.yml

PLAY [Test AIX module aix_lvg] ***********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************
ok: [TESTHOST]

TASK [Test AIX LVM with Invalid PP Values] ***********************************************************************************************************************************************************************************************
failed: [TESTHOST] (item=-32) => {"ansible_loop_var": "item", "changed": false, "item": "-32", "msg": "pp_size must be >0 and a multiple of 2 (supplied: '-32')."}
failed: [TESTHOST] (item=0) => {"ansible_loop_var": "item", "changed": false, "item": 0, "msg": "pp_size must be >0 and a multiple of 2 (supplied: '0')."}
failed: [TESTHOST] (item=129) => {"ansible_loop_var": "item", "changed": false, "item": 129, "msg": "pp_size must be >0 and a multiple of 2 (supplied: '129')."}
failed: [TESTHOST] (item=INVALID) => {"ansible_loop_var": "item", "changed": false, "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"}
        to retry, use: --limit @/root/test_aix_lvg.retry

PLAY RECAP *******************************************************************************************************************************************************************************************************************************
TESTHOST                   : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

@mator
Copy link
Contributor

mator commented Jul 4, 2019

thanks.

just checked on my system, looks good to me.

$ cat aix-pl1.yml
---
- name: Test AIX module aix_lvg
  hosts: aix7
  become: true
  vars:
    hdisk: hdisk1
    vgname: vg_exp1
  tasks:
    - name: "Test AIX LVM with Invalid PP Values"
      become: yes
      aix_lvg:
        force: true
        pp_size: "{{ item }}"
        pvs: "{{ hdisk }}"
        vg: "{{ vgname }}"
        state: present
      with_items:
        - "-4"
        - 0
        - 17
        - "b0rked"

$ ANSIBLE_NOCOWS=1 ansible-playbook aix-pl1.yml 

PLAY [Test AIX module aix_lvg] *****************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************
ok: [aix7]

TASK [Test AIX LVM with Invalid PP Values] *****************************************************************************************************
failed: [aix7] (item=-4) => {"ansible_loop_var": "item", "changed": false, "item": "-4", "msg": "pp_size must be >= 1 and <= 1024, and a multiple of 2 (supplied: '-4')."}
failed: [aix7] (item=0) => {"ansible_loop_var": "item", "changed": false, "item": 0, "msg": "pp_size must be >= 1 and <= 1024, and a multiple of 2 (supplied: '0')."}
failed: [aix7] (item=17) => {"ansible_loop_var": "item", "changed": false, "item": 17, "msg": "pp_size must be >= 1 and <= 1024, and a multiple of 2 (supplied: '17')."}
failed: [aix7] (item=b0rked) => {"ansible_loop_var": "item", "changed": false, "item": "b0rked", "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"}

PLAY RECAP *************************************************************************************************************************************
aix7                       : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 

Copy link
Contributor

@mator mator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ansibot ansibot added owner_pr This PR is made by the module's maintainer. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed new_contributor This PR is the first contribution by a new community member. labels Jul 17, 2019
@d-little
Copy link
Contributor Author

Bumping stale AIX PRs (thanks!) (Close/Reopen for CI checks)

@d-little d-little closed this Aug 26, 2019
@d-little d-little reopened this Aug 26, 2019
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Aug 26, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Sep 3, 2019
@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Mar 29, 2020
@ansibot ansibot added collection Related to Ansible Collections work collection:community.general needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md labels Apr 29, 2020
@Akasurde
Copy link
Member

Akasurde commented Jul 3, 2020

@d-little Thank you very much for your interest in Ansible. This plugin/module is no longer maintained in this repository and has been migrated to community.general. Could you please migrate this PR to the above-mentioned repo?

If you have further questions please stop by IRC or the mailing list:

Thanks,

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Jul 6, 2020
@ansibot
Copy link
Contributor

ansibot commented Aug 8, 2020

@d-little This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Aug 16, 2020

Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.

For further information, please see:
https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md

@ansibot ansibot closed this Aug 16, 2020
@ansible ansible locked and limited conversation to collaborators Sep 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

affects_2.9 This issue/PR affects Ansible v2.9 aix AIX community bot_closed bug This issue/PR relates to a bug. collection:community.general collection Related to Ansible Collections work module This issue/PR relates to a module. needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md needs_info This issue requires further information. Please answer any outstanding questions. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. owner_pr This PR is made by the module's maintainer. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. system System category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants