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

ibm.power_aix.filesystem cannot be executed more than one time #582

Closed
AIXruth opened this issue Dec 11, 2024 · 6 comments
Closed

ibm.power_aix.filesystem cannot be executed more than one time #582

AIXruth opened this issue Dec 11, 2024 · 6 comments
Assignees

Comments

@AIXruth
Copy link

AIXruth commented Dec 11, 2024

I configured a NFS mount point via modul ibm.power_aix.filesystem. It works fine for the first time, but if I execute it a second time it will fail. The error occurs in the function compare_attrs(), because an expected array item does not exist (lines2[2])

To Reproduce
Use a similar task as and execute it more than one time. Afterwards you will get the error and traceback as below:

- name: Ensure NFS mount is defined in /etc/filesystems with dynamic NFS server
  ibm.power_aix.filesystem:
    filesystem: '/mksysb'
    nfs_server: '{{ nfs_server |trim }}'  # 
    state: present
    fs_type: nfs
    device: '{{ dev }}'
    permissions: 'rw'
    auto_mount: true

TASK [/home/myuser/ansible/roles/mksysb : Ensure NFS mount is defined in /etc/filesystems with dynamic NFS server] *****************
task path: /home/myuser/ansible/roles/mksysb/tasks/main.yml:52
ESTABLISH SSH CONNECTION FOR USER: None
SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/myuser/.ansible/cp/d90c328ef5"' myserver '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
(0, b'/home/myuser\n', b'')
ESTABLISH SSH CONNECTION FOR USER: None
SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/myuser/.ansible/cp/d90c328ef5"' myserver '/bin/sh -c '"'"'( umask 77 && mkdir -p "echo /home/myuser/.ansible/tmp"&& mkdir "echo /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634" && echo ansible-tmp-1733907430.024256-32309600-11489077981634="echo /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634" ) && sleep 0'"'"''
(0, b'ansible-tmp-1733907430.024256-32309600-11489077981634=/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634\n', b'')
Using module file /home/myuser/.ansible/collections/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py
PUT /home/myuser/.ansible/tmp/ansible-local-33030636vk8voswm/tmp04tca12l TO /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py
SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/myuser/.ansible/cp/d90c328ef5"' '[myserver]'
(0, b'sftp> put /home/myuser/.ansible/tmp/ansible-local-33030636vk8voswm/tmp04tca12l /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py\n', b'')
ESTABLISH SSH CONNECTION FOR USER: None
SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/myuser/.ansible/cp/d90c328ef5"' myserver '/bin/sh -c '"'"'chmod u+x /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/ /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py && sleep 0'"'"''
(0, b'', b'')
ESTABLISH SSH CONNECTION FOR USER: None
SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/myuser/.ansible/cp/d90c328ef5"' -tt myserver '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-jhzqsvbnvfksjwafkhtglxsshasucpmw ; /opt/freeware/bin/python3.9 /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
(1, b'Traceback (most recent call last):\r\n File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 107, in \r\n _ansiballz_main()\r\n File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 99, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 47, in invoke_module\r\n runpy.run_module(mod_name='ansible_collections.ibm.power_aix.plugins.modules.filesystem', init_globals=dict(_module_fqn='ansible_collections.ibm.power_aix.plugins.modules.filesystem', _modlib_path=modlib_path),\r\n File "/opt/freeware/lib64/python3.9/runpy.py", line 225, in run_module\r\n return _run_module_code(code, init_globals, run_name, mod_spec)\r\n File "/opt/freeware/lib64/python3.9/runpy.py", line 97, in _run_module_code\r\n _run_code(code, mod_globals, init_globals,\r\n File "/opt/freeware/lib64/python3.9/runpy.py", line 87, in _run_code\r\n exec(code, run_globals)\r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 625, in \r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 610, in main\r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 435, in chfs\r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 290, in compare_attrs\r\nIndexError: list index out of range\r\n', b'Shared connection to myserver closed.\r\n')
Failed to connect to the host via ssh: Shared connection to myserver closed.
ESTABLISH SSH CONNECTION FOR USER: None
SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/myuser/.ansible/cp/d90c328ef5"' myserver '/bin/sh -c '"'"'rm -f -r /home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/ > /dev/null 2>&1 && sleep 0'"'"''
(0, b'', b'')
The full traceback is:
Traceback (most recent call last):
File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 107, in
_ansiballz_main()
File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.ibm.power_aix.plugins.modules.filesystem', init_globals=dict(_module_fqn='ansible_collections.ibm.power_aix.plugins.modules.filesystem', _modlib_path=modlib_path),
File "/opt/freeware/lib64/python3.9/runpy.py", line 225, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/opt/freeware/lib64/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/opt/freeware/lib64/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 625, in
File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 610, in main
File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 435, in chfs
File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 290, in compare_attrs
IndexError: list index out of range
fatal: [myserver]: FAILED! => {
"changed": false,
"module_stderr": "Shared connection to myserver closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 107, in \r\n _ansiballz_main()\r\n File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 99, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File "/home/myuser/.ansible/tmp/ansible-tmp-1733907430.024256-32309600-11489077981634/AnsiballZ_filesystem.py", line 47, in invoke_module\r\n runpy.run_module(mod_name='ansible_collections.ibm.power_aix.plugins.modules.filesystem', init_globals=dict(_module_fqn='ansible_collections.ibm.power_aix.plugins.modules.filesystem', _modlib_path=modlib_path),\r\n File "/opt/freeware/lib64/python3.9/runpy.py", line 225, in run_module\r\n return _run_module_code(code, init_globals, run_name, mod_spec)\r\n File "/opt/freeware/lib64/python3.9/runpy.py", line 97, in _run_module_code\r\n _run_code(code, mod_globals, init_globals,\r\n File "/opt/freeware/lib64/python3.9/runpy.py", line 87, in _run_code\r\n exec(code, run_globals)\r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 625, in \r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 610, in main\r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 435, in chfs\r\n File "/tmp/ansible_ibm.power_aix.filesystem_payload_bsmiz3eh/ansible_ibm.power_aix.filesystem_payload.zip/ansible_collections/ibm/power_aix/plugins/modules/filesystem.py", line 290, in compare_attrs\r\nIndexError: list index out of range\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}

Environment (please complete the following information):

  • OS on Server: 7300-02-02-2420
  • OS on Client: 7200-05-06-2320
  • Python Version: python3.9
  • ansible [core 2.14.13]
  • jinja version = 3.1.4
  • OpenSSH Version: 9.2.112.2000
  • AIX Collection Version: 1.9.2. (github download as of 20241211)
@nitismis
Copy link
Member

@schamola , Please make sure that this is fixed and get shipped with our next release.

@schamola
Copy link
Contributor

Hi @AIXruth
Can you please provide the output of this command: lsfs -q /mksysb

@schamola
Copy link
Contributor

@AIXruth
The issue seems to be arising because of the difference between outputs of lsfs -q command in case of JFS/JFS2 and other filesystems (like nfs).
We will push the fix soon!

@AIXruth
Copy link
Author

AIXruth commented Jan 15, 2025

Thank you for the correction. I can confirm from my side that multiple execution is now possible. However, I have noticed two other small errors:

  • On the first run, the mount options are set to “bg, intr”. When executing again, the options are set to “rw,bg,hard,intr”.
  • On further executions, /etc/filesystems is written to, although its content has not changed. With idempotent this should not actually be the case, right?

Both these errors are not relevant in MY case, but I wanted to mention them.

@schamola
Copy link
Contributor

Thanks for confirming that It's working fine for you!

For some attributes, there is inconsistency in naming when using crfs and chfs commands... the issues that you have mentioned could be because of that.
That said, thanks for mentioning them, we will look into them and see if changes are required from our end.

@nitismis
Copy link
Member

Closing this issue, we can have separate issue opened in case we need to change anything in the collection for 2 other errors mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants