# Issue with fstab entry added by ansible mount module its adding white space with \\40 character

**URL:** <https://forum.ansible.com/t/issue-with-fstab-entry-added-by-ansible-mount-module-its-adding-white-space-with-40-character/38356>\
**Category:** Ansible Project\
**Created:** [August 22, 2023, 6:48am UTC](https://forum.ansible.com/t/issue-with-fstab-entry-added-by-ansible-mount-module-its-adding-white-space-with-40-character/38356 "2023-08-22T06:48:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak\_B\_K](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/deepak_b_k/32/5151_2.png) [@Deepak\_B\_K](https://forum.ansible.com/u/Deepak_B_K)\
**Post date:** [August 22, 2023, 6:48am UTC](https://forum.ansible.com/t/issue-with-fstab-entry-added-by-ansible-mount-module-its-adding-white-space-with-40-character/38356/1 "2023-08-22T06:48:48Z")

</div>

Hi Groups,

I am using ansible.builtin.mountd module to mount and add the entry in the fstab in couple of hosts but I see that its adding \040 for the white space . How to get rid of this junk character being added to /etc/fstab?

192.50.250.2:\040/POOL1\040 /POOL1 nfs nfsvers=3,soft,bg,timeo=12\0400\0400 0 0

My code is  
vars:  
mount\_point:

- path: “/P1”  
nfs\_server: “192.50.250.2:”  
source: “/P1”  
fstype: nfs  
opts: “nfsvers=3,soft,bg,timeo=12 0 0”
- path: “/Test-Data”  
nfs\_server: “192.62.150.231:”  
source: “/volume9/Test-Data”  
fstype: nfs  
opts: “nfsvers=3,rw,bg,rsize=131072,wsize=131072,soft,proto=tcp,sec=sys 0 0”

nfs\_mount\_hosts:

- “dev-app601”

- “dev-sgapp601”

- “tst-sgapp601”

- “tst-app601”

- name: Mount NFS directories P1  
become: true  
remote\_user: testops  
ansible.posix.mount:  
fstype: “{{ mount\_point[0].fstype }}”  
src: "{{ mount\_point[0].nfs\_server }} {{ mount\_point[0].source }} "  
path: “{{ mount\_point[0].path}}”  
opts: “{{ mount\_point[0].opts }}”  
state: mounted  
delegate\_to: “{{ item }}”  
loop: “{{ nfs\_mount\_hosts }}”

I appreciate your help.

Thanks  
Deepak Kumar

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [August 22, 2023, 11:21am UTC](https://forum.ansible.com/t/issue-with-fstab-entry-added-by-ansible-mount-module-its-adding-white-space-with-40-character/38356/2 "2023-08-22T11:21:33Z")

</div>

Note that “\040” is octal. The hex equivalent is 0x20 or decimal 32, a.k.a. and ascii space.

If the octal expression is being expressed in your /etc/fstab rather than the literal space character, that sound like a bug. Which versions of Ansible and ansible.posix are you using?

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [August 22, 2023, 11:39am UTC](https://forum.ansible.com/t/issue-with-fstab-entry-added-by-ansible-mount-module-its-adding-white-space-with-40-character/38356/3 "2023-08-22T11:39:46Z")

</div>

Hi,

please take a look at your task:

> - name: Mount NFS directories P1  
> &nbsp;&nbsp;&nbsp;become: true  
> &nbsp;&nbsp;&nbsp;remote\_user: testops  
> &nbsp;&nbsp;&nbsp;ansible.posix.mount:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fstype: "{{ mount\_point[0].fstype }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src: "{{ mount\_point[0].nfs\_server }} {{ mount\_point[0].source  
> }} "

you are \*explicitly\* asking for `src` to have a space in the middle and  
one at the end. Since spaces are used as separators in /etc/fstab, the  
module correctly quotes your `src` value with space being replaced by  
\040.

The same is true for \040 in the options, that comes from the value you  
provide, which contains spaces:

> &nbsp;&nbsp;&nbsp;&nbsp;opts: "nfsvers=3,soft,bg,timeo=12 0 0"

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Deepak\_B\_K](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/deepak_b_k/32/5151_2.png) [@Deepak\_B\_K](https://forum.ansible.com/u/Deepak_B_K)\
**Post date:** [August 23, 2023, 5:44am UTC](https://forum.ansible.com/t/issue-with-fstab-entry-added-by-ansible-mount-module-its-adding-white-space-with-40-character/38356/4 "2023-08-23T05:44:34Z")

</div>

Hi Lewis ,

I am using the v 1.5.4 for ansible.posix version

ansible [core 2.13.4]  
config file = /home/deep/admin\_git/cicd\_gkr\_admin\_release/ansible.cfg  
configured module search path = [‘/home/deep/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /home/deep/.local/lib/python3.10/site-packages/ansible  
ansible collection location = /home/deep/.ansible/collections:/usr/share/ansible/collections  
executable location = /home/deep/.local/bin/ansible  
python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]  
jinja version = 3.1.2

# /home/deep/.ansible/collections/ansible\_collections

Collection Version

* * *

ansible.posix 1.5.4

thanks  
Deepak Kumar

---

<div class="post-metadata">

**Author:** ![Deepak\_B\_K](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/deepak_b_k/32/5151_2.png) [@Deepak\_B\_K](https://forum.ansible.com/u/Deepak_B_K)\
**Post date:** [August 23, 2023, 5:52am UTC](https://forum.ansible.com/t/issue-with-fstab-entry-added-by-ansible-mount-module-its-adding-white-space-with-40-character/38356/5 "2023-08-23T05:52:42Z")

</div>

Hi Felix ,

Thank you for the input. By combining the src and nfs servers to src variable I am able to get rid of one space but I have a variable path where I have this problem. not sure how to handle variable path? and for the opts i did get rid of fsck check which will default is zero

source: “192.50.250.2:/P1”

opts: “nfsvers=3,soft,bg,timeo=12”

10.50.226.248:/POOL1\*\*\040\*\* /POOL1 nfs nfsvers=3,soft,bg,timeo=12 0 0

I am just looking to get rid of the \040 on the path variable.

Thanks,  
Deepak Kumar
