Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new module: aix_devices, manage AIX devices #32290

Merged
merged 14 commits into from
Feb 4, 2019

Conversation

kairoaraujo
Copy link
Contributor

SUMMARY

New module for AIX.
This module discovers, defines, removes and modifies attributes of AIX devices.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

lib/ansible/modules/system/aix_devices.py

ANSIBLE VERSION
ansible 2.5.0 (aix_devices 975f695d1b) last updated 2017/10/28 12:39:51 (GMT +200)
  config file = None
  configured module search path = ['/Users/kairo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/kairo/Dev/Ansible/modules/aix_devices/ansible/lib/ansible
  executable location = /Users/kairo/Dev/Ansible/modules/aix_devices/ansible/bin/ansible
  python version = 3.6.3 (v3.6.3:2c5fed86e0, Oct  3 2017, 00:32:08) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
ADDITIONAL INFORMATION

There is an example of playbook testing possibilities and playbook returns

---
- name: Testing
  hosts: lpar22

  tasks:
    - name: Scan new devices.
      aix_devices:
        device: all
        state: present

    - name: Scan new virtual devices (vio0).
      aix_devices:
        device: vio0
        state: present

    - name: Removes ent2.
      aix_devices:
        device: ent2
        state: absent

    - name: Put device en2 in Defined
      aix_devices:
        device: en2
        state: defined

    - name: Removes ent4 (inexistent).
      aix_devices:
        device: ent4
        state: absent

    - name: Put device en4 in Defined (inexistent)
      aix_devices:
        device: en4
        state: defined

    - name: Put vscsi1 and children devices in Defined state.
      aix_devices:
        device: vscsi1
        recursive: yes
        state: defined

    - name: Removes vscsi1 and children devices.
      aix_devices:
        device: vscsi1
        recursive: yes
        state: absent

    - name: Changes en1 mtu to 9000 and disables arp.
      aix_devices:
        device: en1
        attributes: mtu=900,arp=off
        state: present

    - name: Configure IP, netmask and set en1 up.
      aix_devices:
        device: en1
        attributes: netaddr=192.168.0.100,netmask=255.255.255.0,state=up
        state: present

    - name: Adding IP alias to en0
      aix_devices:
        device: en0
        attributes: [
            "alias4=10.0.0.100,255.255.255.0"
            ]
        state: present

Playbook running:

ansible-playbook -i ../../../inventory ../test.yml -v
No config file found; using defaults

PLAY [Testing] ************************************************************************************************

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

TASK [Scan new devices.] **************************************************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "", "state": "present"}

TASK [Scan new virtual devices (vio0).] ***********************************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "", "state": "present"}

TASK [Removes ent2.] ******************************************************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "ent2 deleted\n", "state": "absent"}

TASK [Put device en2 in Defined] ******************************************************************************
ok: [lpar22] => {"changed": false, "failed": false, "msg": "Device en2 already in Defined", "state": "defined"}

TASK [Removes ent4 (inexistent).] *****************************************************************************
ok: [lpar22] => {"changed": false, "failed": false, "msg": "Device ent4 does not exist.", "state": "absent"}

TASK [Put device en4 in Defined (inexistent)] *****************************************************************
ok: [lpar22] => {"changed": false, "failed": false, "msg": "Device en4 does not exist.", "state": "defined"}

TASK [Put vscsi1 and children devices in Defined state.] ******************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "vscsi1 Defined\n", "state": "defined"}

TASK [Removes vscsi1 and children devices.] *******************************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "vscsi1 deleted\n", "state": "absent"}

TASK [Changes en1 mtu to 9000 and disables arp.] **************************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "Attributes changed: arp=off. Attributes already set: mtu=900. ", "state": "present"}

TASK [Configure IP, netmask and set en1 up.] ******************************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "Attributes changed: netaddr=192.168.0.100,netmask=255.255.255.0,state=up. ", "state": "present"}

TASK [Adding IP alias to en0] *********************************************************************************
changed: [lpar22] => {"changed": true, "failed": false, "msg": "Attributes changed: alias4=10.0.0.100,255.255.255.0. ", "state": "present"}

PLAY RECAP ****************************************************************************************************
lpar22                     : ok=12   changed=8    unreachable=0    failed=0


This module discovery, defines, removes and modifies attributes of AIX
devices.
Added hid attributes that can be used to manage aliases on en
interfaces.
Fixed attributes tests and doc explaining how to use
attributes with comma.
Fixed grammar on module description
@ansibot
Copy link
Contributor

ansibot commented Oct 28, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 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_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Oct 28, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Oct 30, 2017
@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 Nov 7, 2017
As discussed on IRC ansible-devel channes, was include the
legacy tests for further manual tests.
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. and removed community_review In order to be merged, this PR must follow the community review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 15, 2018
lib/ansible/modules/system/aix_devices.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_devices.py Outdated Show resolved Hide resolved
lib/ansible/modules/system/aix_devices.py Outdated Show resolved Hide resolved
@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 Jan 26, 2018
Added 'attributes' as a dictionary makes the configuration
simple.
@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 Jun 1, 2018
Fixed the shippable error from 2.5 to 2.7

```
2018-06-01 08:28:02 ERROR: Found 1 validate-modules issue(s) which
need to be resolved:
2018-06-01 08:28:02 ERROR:
lib/ansible/modules/system/aix_devices.py:0:0: E307 version_added
should be 2.7. Currently 2.5 (75%)
```
@ansibot

This comment has been minimized.

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. ci_verified Changes made in this PR are causing tests to fail. labels Jun 1, 2018
@ansibot

This comment has been minimized.

@ansibot
Copy link
Contributor

ansibot commented Jan 29, 2019

cc @mator
click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 29, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 29, 2019
'available' state is the AIX state used, that works same as 'present'
@ansibot

This comment has been minimized.

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jan 30, 2019
Makes sense keep the states names to AIX and use the Ansible 'standards'
states.

'available' is 'present'
'removed' is 'absent'

It makes easy to AIX sysadmins use the module, however it keep the
Ansible meanings.
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 30, 2019
@ansibot

This comment has been minimized.

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jan 30, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 30, 2019
@gforster
Copy link
Contributor

Looks good. I should be able to test tomorrow

Sent with GitHawk

@kairoaraujo
Copy link
Contributor Author

@ramooncamacho it is ready for tests

Nothing material
@dagwieers
Copy link
Contributor

rebuild_merge

@ansibot ansibot removed the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Feb 4, 2019
@dagwieers dagwieers merged commit a355686 into ansible:devel Feb 4, 2019
@ramooncamacho
Copy link

@dagwieers and @kairoaraujo, should I just comment my tests or do I open the issues? I will start sending the comments here:

Issue 1:

Please change in the example page from present to available, and from absent to removed, as the options have changed.

Issue 2:

Trying to discover all devices, it was returned changed as true, but the new device didn't show up.

I think it should be expected this command be always status changed, but I noticed an hidden error, because in AIX if an object class doesn't exist, the return code is still 0:

Trying to discover all devices:

[testuser@controller ansible]$ ansible -s -m aix_devices -a 'device=all state=available' testeram
testeram | CHANGED => {
    "changed": true,
    "msg": ""
}
[testuser@controller ansible]$ 

I realized the new devices didn't show up:

testuser@testeram(/home/testuser)# lsdev -C | grep fcs
testuser@testeram(/home/testuser)#

The module is trying to execute "cfgmgr -l all", and doing it manually, the command is trying to find a device named "all". To discover all devices I have always used cfgmgr with no option, as below:

testuser@testeram(/home/testuser)# lsdev -C | grep fcs
testuser@testeram(/home/testuser)# sudo cfgmgr -l all
cfgmgr: 0514-604 Cannot access the CuDv object class in the
        device configuration database.
testuser@testeram(/home/testuser)# lsdev -C | grep fcs
testuser@testeram(/home/testuser)# sudo cfgmgr
testuser@testeram(/home/testuser)# lsdev -C | grep fcs
fcs0       Available 29-T1       Virtual Fibre Channel Client Adapter
testuser@testeram(/home/testuser)#

Return code in the condition the object class is not found:

testuser@testeram(/home/testuser)# sudo cfgmgr -l all
cfgmgr: 0514-604 Cannot access the CuDv object class in the
        device configuration database.
testuser@testeram(/home/testuser)# echo $?
0
testuser@testeram(/home/testuser)#

Issue 3:

Trying to remove an adapter, it returns error:

[testuser@controller ansible]$ cat aix_dev.yaml
---
- name: Testing
  hosts: testeram
  become: yes

  tasks:
    - name: Removes fcs0.
      aix_devices:
        device: fcs0
        state: removed
        recursive: yes
[testuser@controller ansible]$
[testuser@controller ansible]$ ansible-playbook aix_dev.yaml

PLAY [Testing] *********************************************************************************************************************************************************

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

TASK [Removes fcs0.] ***************************************************************************************************************************************************
fatal: [testeram]: FAILED! => {"changed": false, "err": "rmdev: 0514-500 Usage error - \n\nUsage:\nrmdev {-l|-p} Name [-d|-S][-R][-q][-f File][-g]\nrmdev -h\n\n", "msg": "Failed to run rmdev", "rc": 1}
        to retry, use: --limit @/home/testuser/ansible/aix_dev.retry

PLAY RECAP *************************************************************************************************************************************************************
testeram                   : ok=1    changed=0    unreachable=0    failed=1    skipped=0

[testuser@controller ansible]$

I saw it's trying to execute "/usr/sbin/rmdev -l fcs0 -R ''", and doing the same at the operating system, it returns error:

testuser@testeram(/home/testuser)# sudo /usr/sbin/rmdev -l fcs0 -R ''
rmdev: 0514-500 Usage error -

Usage:
rmdev {-l|-p} Name [-d|-S][-R][-q][-f File][-g]
rmdev -h

testuser@testeram(/home/testuser)#

If I do the same without the single quotation marks, it executes correctly:

testuser@testeram(/home/testuser)# sudo /usr/sbin/rmdev -l fcs0 -R
sfwcomm0 Defined
fscsi0 Defined
fcs0 Defined
testuser@testeram(/home/testuser)#

@dagwieers
Copy link
Contributor

@ramooncamacho Please open issues for each. Thanks for testing !

@ramooncamacho
Copy link

The issues were opened:

#51750
#51754
#51755

@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 aix AIX community module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants