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

ansible.posix.mount module doesn't work #21

Closed
yizhanglinux opened this issue May 1, 2020 · 4 comments
Closed

ansible.posix.mount module doesn't work #21

yizhanglinux opened this issue May 1, 2020 · 4 comments
Assignees

Comments

@yizhanglinux
Copy link

SUMMARY

ansible.posix.mount module doesn't work

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mount

ANSIBLE VERSION

[root@storageqe-62 ~]# ansible --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code
and can become unstable at any point.
ansible 2.10.0.dev0
config file = /root/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible_base-2.10.0.dev0-py3.6.egg/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Dec 5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

CONFIGURATION

OS / ENVIRONMENT

RHEL8.2

STEPS TO REPRODUCE

[root@storageqe-62 ~]# ansible-galaxy collection install ansible.posix
[root@storageqe-62 ~]# lsblk
NAME                        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                           8:0    0 279.4G  0 disk 
├─sda1                        8:1    0   600M  0 part /boot/efi
├─sda2                        8:2    0     1G  0 part /boot
└─sda3                        8:3    0 277.8G  0 part 
  ├─rhel_storageqe--62-root 253:0    0    50G  0 lvm  /
  ├─rhel_storageqe--62-swap 253:1    0   7.9G  0 lvm  [SWAP]
  └─rhel_storageqe--62-home 253:2    0   220G  0 lvm  /home
sdb                           8:16   0 279.4G  0 disk 
sdc                           8:32   0 186.3G  0 disk 
sdd                           8:48   0 111.8G  0 disk 
sde                           8:64   0 111.8G  0 disk 
sdf                           8:80   0 931.5G  0 disk 
sdg                           8:96   0 931.5G  0 disk 
sdh                           8:112  0 931.5G  0 disk 
sdi                           8:128  0 931.5G  0 disk 
sdj                           8:144  0 931.5G  0 disk 
sdk                           8:160  0 279.4G  0 disk 
sdl                           8:176  0 279.4G  0 disk 
└─sdl1                        8:177  0 279.4G  0 part /root/test
nvme0n1                     259:0    0 745.2G  0 disk 
[root@storageqe-62 ~]# cat mount1.yml 
---
- hosts: localhost
  collections:
   - ansible.posix
  tasks:
     - name: test mount
       mount: 
         src: /dev/nvme0n1
         path: /mnt
         fstype: ext4 
         state: mounted
[root@storageqe-62 ~]# ansible-playbook mount1.yml 
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [localhost] *****************************************************************************************************************************************************************************************************************************************************************************************************************************

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

TASK [test mount] ****************************************************************************************************************************************************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'module' object is not callable
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1588344023.191913-7960-159675219017070/AnsiballZ_mount.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1588344023.191913-7960-159675219017070/AnsiballZ_mount.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1588344023.191913-7960-159675219017070/AnsiballZ_mount.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.ansible.posix.plugins.modules.mount', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_mount_payload_k_zs2wmx/ansible_mount_payload.zip/ansible_collections/ansible/posix/plugins/modules/mount.py\", line 764, in <module>\n  File \"/tmp/ansible_mount_payload_k_zs2wmx/ansible_mount_payload.zip/ansible_collections/ansible/posix/plugins/modules/mount.py\", line 733, in main\nTypeError: 'module' object is not callable\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

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

EXPECTED RESULTS

mount module works well

ACTUAL RESULTS

mount module doesn't work

@yizhanglinux
Copy link
Author

Seems the ismount module doesn't work here.

@gundalow
Copy link
Contributor

gundalow commented May 4, 2020

@yizhanglinux Thank you for taking the time to raise this. It appears to be a bug in ansible-base.

There is a proposed fix in ansible/ansible#68223, does that work for you?

@yizhanglinux
Copy link
Author

yizhanglinux commented May 4, 2020

@yizhanglinux Thank you for taking the time to raise this. It appears to be a bug in ansible-base.

There is a proposed fix in ansible/ansible#68223, does that work for you?

Still doesn't work, from the log seems the ismount module still not callable

TASK [test mount] ****************************************************************************************************************************************************************************************************************************
task path: /root/mount1.yml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698 && echo ansible-tmp-1588608300.4785476-4044-173318253611698="` echo /root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/ansible/posix/plugins/modules/mount.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-3889ezjttpu1/tmp6shykdin TO /root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/ /root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py", line 102, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.ansible.posix.plugins.modules.mount', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_mount_payload_uxdbm1n5/ansible_mount_payload.zip/ansible_collections/ansible/posix/plugins/modules/mount.py", line 764, in <module>
  File "/tmp/ansible_mount_payload_uxdbm1n5/ansible_mount_payload.zip/ansible_collections/ansible/posix/plugins/modules/mount.py", line 733, in main
TypeError: 'module' object is not callable
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1588608300.4785476-4044-173318253611698/AnsiballZ_mount.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.ansible.posix.plugins.modules.mount', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_mount_payload_uxdbm1n5/ansible_mount_payload.zip/ansible_collections/ansible/posix/plugins/modules/mount.py\", line 764, in <module>\n  File \"/tmp/ansible_mount_payload_uxdbm1n5/ansible_mount_payload.zip/ansible_collections/ansible/posix/plugins/modules/mount.py\", line 733, in main\nTypeError: 'module' object is not callable\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

@maxamillion
Copy link
Collaborator

confirmed with ansible 2.9 but not with ansible 2.10beta ... so now on to bisecting :)

maxamillion added a commit to maxamillion/ansible.posix that referenced this issue Jun 19, 2020
In Ansible 2.9 (pre 2.10 routing), the AnsiballZ creation of the payload
will add an extra directory to the module_util path because ismount.py
shares the same name as it's parent dir which creates an inconsistency
in the payload creation. This causes the Collection module
ansible.posix.mount to work in Ansible 2.10 but not 2.9, with this pull
request a simple renaming of the module_util which side steps this
inconsistency.

Fixes ansible-collections#21

Signed-off-by: Adam Miller <admiller@redhat.com>
@ansible-zuul ansible-zuul bot closed this as completed in 01d06f6 Jun 19, 2020
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