-
Notifications
You must be signed in to change notification settings - Fork 167
Description
SUMMARY
If the "path" parameter is specified with a quoted string that contains a leading space, this is interpreted as a valid relative path with " " (single space) as the name of the first folder and "test" (in this example here) as a subfolder.
ISSUE TYPE
- Bug Report
COMPONENT NAME
ansible.posix.mount
ANSIBLE VERSION
ansible --version
ansible [core 2.16.3]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.12/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.12.11 (main, Jun 19 2025, 11:41:33) [GCC 8.5.0 20210514 (Red Hat 8.5.0-27)] (/usr/bin/python3.12)
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
Collection Version
------------- -------
ansible.posix 2.0.0
CONFIGURATION
# ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg
GALAXY_SERVER_LIST(/etc/ansible/ansible.cfg) = ['galaxy_redhat_certified', 'galaxy_redhat_validated']
OS / ENVIRONMENT
Red Hat Enterprise Linux release 8.10 (Ootpa)
STEPS TO REPRODUCE
---
- name: Demonstrate mount issue
hosts: localhost
connection: local
tasks:
- name: Mount
ansible.posix.mount:
src: /tmp
path: " /test"
fstype: none
opts: bind
state: mounted
EXPECTED RESULTS
ansible.posix.mount can handle the whitespace on the path
ACTUAL RESULTS
The module then creates this relative path in the current working directory (so where that ansible is run from) with name set to a space ' '
The example playbook demonstrates this. If run in /root it will create the following path: "/root/ /test" and mount the src there
/etc/fstab entry:
/tmp \040/test none bind 0 0
mount command output:
/dev/mapper/rhel-root on /root/ /test type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
TASK [Mount] ****************************************************************************************************************************************************************
task path: /root/04197809.yml:7
<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 "` echo /root/.ansible/tmp/ansible-tmp-1752668315.0079315-6033-33368484476636 `" && echo ansible-tmp-1752668315.0079315-6033-33368484476636="` echo /root/.ansible/tmp/ansible-tmp-1752668315.0079315-6033-33368484476636 `" ) && 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-5978fy4z_mz4/tmpbv2btspd TO /root/.ansible/tmp/ansible-tmp-1752668315.0079315-6033-33368484476636/AnsiballZ_mount.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1752668315.0079315-6033-33368484476636/ /root/.ansible/tmp/ansible-tmp-1752668315.0079315-6033-33368484476636/AnsiballZ_mount.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3.12 /root/.ansible/tmp/ansible-tmp-1752668315.0079315-6033-33368484476636/AnsiballZ_mount.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1752668315.0079315-6033-33368484476636/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"backup_file": "",
"boot": "yes",
"changed": true,
"dump": "0",
"fstab": "/etc/fstab",
"fstype": "none",
"invocation": {
"module_args": {
"backup": false,
"boot": true,
"dump": "0",
"fstab": null,
"fstype": "none",
"opts": "bind",
"opts_no_log": false,
"passno": "0",
"path": " /test",
"src": "/tmp",
"state": "mounted"
}
},
"name": " /test",
"opts": "bind",
"passno": "0",
"src": "/tmp"
}