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

Skip to content

new module: Configure LVM and NFS file systems for AIX#30810

Merged
dagwieers merged 11 commits intoansible:develfrom
kairoaraujo:aix_filesystem
Jan 5, 2019
Merged

new module: Configure LVM and NFS file systems for AIX#30810
dagwieers merged 11 commits intoansible:develfrom
kairoaraujo:aix_filesystem

Conversation

@kairoaraujo
Copy link
Contributor

SUMMARY

This module creates, removes, mount and unmount LVM and NFS file system for AIX using /etc/filesystems. For LVM file systems is possible to resize a file system.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

aix_filesystem

ANSIBLE VERSION
ansible 2.5.0 (aix_filesystem e984ea3edb) last updated 2017/09/24 10:57:14 (GMT +200)
  config file = None
  configured module search path = ['/Users/kairoaraujo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/kairoaraujo/Dev/Ansible/modules/aix_filesystem/ansible/lib/ansible
  executable location = /Users/kairoaraujo/Dev/Ansible/modules/aix_filesystem/ansible/bin/ansible
  python version = 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
ADDITIONAL INFORMATION

Functional tests.

aix_fs.yml

---
- name: testing aix_filesystem module
  hosts: 172.16.100.24
  tasks:
    - name: Umounting /testfs
      aix_filesystem:
        filesystem: /testfs
        state: unmounted

    - name: Removing /testfs
      aix_filesystem:
        filesystem: /testfs
        state: absent

    - name: Creating a new file system
      aix_filesystem:
        filesystem: /newfs
        size: 1G
        state: present
        vg: datavg

   - name: Creating NFS filesystem from nfshost (Linux NFS server)
    aix_filesystem:
      device: /home/ftp
      nfs_server: nfshost
      filesystem: /nfs/ftp
      state: present

    - name: Creating a logical volume testlv (aix_lvol module)
      aix_lvol:
        vg: datavg
        lv: testlv
        size: 2G
        state: present

    - name: Create filesystem in a previously defined logical volume
      aix_filesystem:
        device: testlv
        filesystem: /testfs
        state: present

    - name: Create an already existing filesystem using existing logical volume.
      aix_filesystem:
        vg: datavg
        device: mksysblv
        filesystem: /mksysb
        state: present

    - name: Create a filesystem in a non-existing VG
      aix_filesystem:
        vg: nonexistvg
        filesystem: /newlv
        state: present

    - name: Resizing /mksysb to 1G
      aix_filesystem:
        filesystem: /mksysb
        size: 1G
        state: present

    - name: Resizing /mksysb to +512M
      aix_filesystem:
        filesystem: /mksysb
        size: +512M
        state: present

    - name: Resizing /mksysb to 11G
      aix_filesystem:
        filesystem: /mksysb
        size: 11G
        state: present

    - name: Resizing /mksysb to 11G (already done)
      aix_filesystem:
        filesystem: /mksysb
        size: 11G
        state: present

    - name: Resizing /mksysb to -2G
      aix_filesystem:
        filesystem: /mksysb
        size: -2G
        state: present

    - name: Resizing /mksysb to 100G (no enought space)
      aix_filesystem:
        filesystem: /mksysb
        size: +100G
        state: present

    - name: Unmount filesystem /home/ftp
      aix_filesystem:
        filesystem: /home/ftp
        state: unmounted

    - name: Remove NFS filesystem /home/ftp
      aix_filesystem:
        filesystem: /home/ftp
        rm_mount_point: yes
        state: absent

    - name: Mount filesystem /newfs
      aix_filesystem:
        filesystem: /newfs
        state: mounted

    - name: Remove mounted /newfs
      aix_filesystem:
        filesystem: /newfs
        rm_mount_point: yes
        state: absent

    - name: Umount /newfs
      aix_filesystem:
        filesystem: /newfs
        state: unmounted

    - name: Remove /newfs
      aix_filesystem:
        filesystem: /newfs
        rm_mount_point: yes
        state: absent

output

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

PLAY [testing aix_filesystem module] **************************************************************************************************

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

TASK [Umounting /testfs] **************************************************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "File system /testfs already unmounted.", "state": "unmounted"}

TASK [Removing /testfs] ***************************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "rmlv: Logical volume testlv is removed.\n", "state": "absent"}

TASK [Creating a new file system] *****************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "File system created successfully.\n1048340 kilobytes total disk space.\nNew File System size is 2097152\n", "state": "present"}

TASK [Creating NFS filesystem from nfshost (Linux NFS server)] ************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "File system /nfs/ftp already exists.", "state": "present"}

TASK [Creating a logical volume testlv (aix_lvol module)] *****************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "Logical volume testlv created."}

TASK [Create filesystem in a previously defined logical volume] ***********************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "File system created successfully.\n2096884 kilobytes total disk space.\nNew File System size is 4194304\n", "state": "present"}

TASK [Create an already existing filesystem using existing logical volume.] ***********************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "File system /mksysb already exists.", "state": "present"}

TASK [Create a filesystem in a non-existing VG] ***************************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "Volume group nonexistvg does not exist.", "state": "present"}

TASK [Resizing /mksysb to 1G] *********************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "Filesystem size changed to 2097152\n", "state": "present"}

TASK [Resizing /mksysb to +512M] ******************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "Filesystem size changed to 3145728\n", "state": "present"}

TASK [Resizing /mksysb to 11G] ********************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "Filesystem size changed to 23068672\n", "state": "present"}

TASK [Resizing /mksysb to 11G (already done)] *****************************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "The filesystem size is already 23068672.\n", "state": "present"}

TASK [Resizing /mksysb to -2G] ********************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "Filesystem size changed to 18874368\n", "state": "present"}

TASK [Resizing /mksysb to 100G (no enought space)] ************************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "0516-787 extendlv: Maximum allocation for logical volume mksysblv\n\tis 512.\n", "state": "present"}

TASK [Unmount filesystem /home/ftp] ***************************************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "File system /home/ftp already unmounted.", "state": "unmounted"}

TASK [Remove NFS filesystem /home/ftp] ************************************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "File system /home/ftp does not exist.", "state": "absent"}

TASK [Mount filesystem /newfs] ********************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "File system /newfs mounted.", "state": "mounted"}

TASK [Remove mounted /newfs] **********************************************************************************************************
ok: [172.16.100.24] => {"changed": false, "failed": false, "msg": "File system /newfs mounted.", "state": "absent"}

TASK [Umount /newfs] ******************************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "File system /newfs unmounted.", "state": "unmounted"}

TASK [Remove /newfs] ******************************************************************************************************************
changed: [172.16.100.24] => {"changed": true, "failed": false, "msg": "rmlv: Logical volume fslv00 is removed.\n", "state": "absent"}

PLAY RECAP ****************************************************************************************************************************
172.16.100.24              : ok=21   changed=11   unreachable=0    failed=0

This module creates, removes, mount and unmount LVM and NFS file system
for AIX using /etc/filesystems. For LVM file systems is also possible
to resize the file system.
better parameters options structure
Added better tratment for return codes for file system resize.
When a resize is not possible because no enough space on lv or
shrink is not allowed.
- improved doc
- creation file system return code 10 was treated.
@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 Sep 24, 2017
@ansibot
Copy link
Contributor

ansibot commented Sep 24, 2017

@ansibot ansibot added 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 Sep 24, 2017
Copy link
Contributor

@dagwieers dagwieers left a comment

Choose a reason for hiding this comment

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

So looking at the code, I think the main part could use a generic result dictionary that is modified as you go.

result = dict(
    changed=False
)

And then you can set it to changed whenever there's a change induced.

result['changed'] = True
result['msg'] = 'Foo bar'

And when you call fail_json() or exit_json() you can simply provide it the dictionary:

if something:
    fail_json(**result)

exit_json(**result)

This ensures that if you make a change, but it fails subsequently, you return the change-flag on failure as well.

@dagwieers
Copy link
Contributor

dagwieers commented Sep 25, 2017

It would probably be best to also include integration tests. Not that they will be run as part of Shippable (as we don't have AIX targets), but it is useful for contributors (and maintainers) to test if the module still works as expected.

(And you already have these tests)

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Sep 28, 2017
@kairoaraujo
Copy link
Contributor Author

Hi @dagwieers

I'm blocked with integration tests.

Should I write ansible-test aix-integration to support a specific inventory to run it? (I already tried it but I receive error[1])

Write the integration tests is ok, but how can I run this tests by myself?
Is it possible using ansible-test integration --remote ???

I would like run the test in my environment.

Thanks in advance to help me with that.

[1]

ansible-test -h
usage: ansible-test [-h] COMMAND ...

positional arguments:
  COMMAND
    integration        posix integration tests
    network-integration
                       network integration tests
    windows-integration
                       windows integration tests
    aix-integration    aix integration tests
    units              unit tests
    compile            compile tests
    sanity             sanity tests
    shell              open an interactive shell
    coverage           code coverage management and reporting

optional arguments:
  -h, --help           show this help message and exit


ansible-test aix-integration --aix test/integration/inventory.aixremote.template aix_filesystem
Traceback (most recent call last):
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/ansible-test", line 696, in <module>
    main()
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/ansible-test", line 92, in main
    args.func(config)
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/lib/executor.py", line 403, in command_aix_integration
    remotes = [instance.wait_for_result() for instance in instances]
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/lib/thread.py", line 48, in wait_for_result
    exec('raise exception[0], exception[1], exception[2]')  # pylint: disable=locally-disabled, exec-used
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/lib/thread.py", line 34, in run
    self._result.put((self.action(), None))
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/lib/executor.py", line 427, in aix_run
    core_ci.start()
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/lib/core_ci.py", line 149, in start
    return self.start_remote()
  File "/Users/kairo/Dev/Ansible/aix_integration/ansible/test/runner/lib/core_ci.py", line 153, in start_remote
    with open(self.ci_key, 'r') as key_fd:
IOError: [Errno 2] No such file or directory: '/Users/kairo/.ansible-core-ci.key'

@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 Oct 5, 2017
- Added doc recomendations
- Changed return to dict results on main()
- Using 159 columns for code limit
@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 Oct 9, 2017
@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Oct 17, 2017
Fixed wrong changed return when file system is already mounted.
When the file system is already mounted the return for changed
is False.
@ansibot ansibot 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. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Nov 2, 2017
Copy link
Contributor

@jtyr jtyr 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 stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Nov 10, 2017
- Fixed description
- Included playbook for manual tests
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. 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. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Jan 23, 2018
@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Feb 6, 2018
@ansibot
Copy link
Contributor

ansibot commented Sep 19, 2018

@gforster
Copy link
Contributor

gforster commented Jan 4, 2019

@mattclay
@jtyr
@dagwieers
@jborean93

What needs to be done here to get this merged?

Copy link
Contributor

@dagwieers dagwieers left a comment

Choose a reason for hiding this comment

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

LGTM, although there are still a few review items open.
Then we can merge this.

@ansibot ansibot removed the stale_review Updates were made after the last review and the last review is more than 7 days old. label Jan 5, 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 Jan 5, 2019
…_filesystem/tasks/main.yml

Move integration test to its proper location
@ansibot ansibot removed the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jan 5, 2019
@dagwieers dagwieers dismissed their stale review January 5, 2019 01:11

Made the required modifications

Copy link
Contributor

@dagwieers dagwieers left a comment

Choose a reason for hiding this comment

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

LGTM, waiting for CI to succeed.

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 5, 2019
@dagwieers dagwieers merged commit fc6d85e into ansible:devel Jan 5, 2019
@dagwieers dagwieers added the aix AIX community label Jan 8, 2019
kbreit pushed a commit to kbreit/ansible that referenced this pull request Jan 11, 2019
* new module: AIX LVM file system and NFS

This module creates, removes, mount and unmount LVM and NFS file system
for AIX using /etc/filesystems. For LVM file systems is also possible
to resize the file system.

* better parameters options structure

better parameters options structure

* Improved file system resize returns

Added better tratment for return codes for file system resize.
When a resize is not possible because no enough space on lv or
shrink is not allowed.

* improved doc and creation file system return code

- improved doc
- creation file system return code 10 was treated.

* Doc recomendations, dict result, line limit

- Added doc recomendations
- Changed return to dict results on main()
- Using 159 columns for code limit

* wrong changed return when file system is already

Fixed wrong changed return when file system is already mounted.
When the file system is already mounted the return for changed
is False.

* Fixed description and included playbook for tests

- Fixed description
- Included playbook for manual tests

* Various small bits to get this merged ASAP

* Rename test/legacy/aix_filesystem.yml to test/integration/targets/aix_filesystem/tasks/main.yml

Move integration test to its proper location

* Create aliases

* Fix CI issues
@kairoaraujo kairoaraujo mentioned this pull request Jan 30, 2019
@ansible ansible locked and limited conversation to collaborators Jul 22, 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 community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. 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.

6 participants