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

mount module does not add mountpoint correctly if /etc/fstab does not end with a newline #210

Closed
saito-hideki opened this issue Jun 15, 2021 · 0 comments · Fixed by #211
Closed
Labels
bug This issue/PR relates to a bug. has_pr verified This issue has been verified/reproduced by maintainer

Comments

@saito-hideki
Copy link
Collaborator

SUMMARY

mount module does not add mountpoint correctly if /etc/fstab does not end with a newline.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • ansible.posix.mount
ANSIBLE VERSION
2.12.0.dev0
CONFIGURATION

[1] ansible.cfg

$ ansible-config dump --only-changed
CALLBACKS_ENABLED(/home/hsaito/work/testing/collections/ansible.cfg) = ['ansible.posix.profile_tasks']
COLLECTIONS_PATHS(/home/hsaito/work/testing/collections/ansible.cfg) = ['/home/hsaito/work/testing/collections']
DISPLAY_SKIPPED_HOSTS(/home/hsaito/work/testing/collections/ansible.cfg) = False
HOST_KEY_CHECKING(/home/hsaito/work/testing/collections/ansible.cfg) = False

[2] Playbook

---
- hosts: linux
  gather_facts: false

  tasks:
    - ansible.posix.mount:
        src: /dev/vdb1
        path: /mnt
        opts: defaults
        state: mounted
        fstype: xfs
        state: mounted
      become: true

[3] There is no newline at the end of file of /etc/fstab:

[root@server00 ~]# cat /etc/fstab 
... snip ...
/dev/mapper/cl-root     /                       xfs     defaults        0 0
UUID=fd99bb22-3376-434f-b976-f0e0845ddf1b /boot                   ext4    defaults        1 2
/dev/mapper/cl-swap     swap                    swap    defaults        0 0

# No newline at EOF[root@server00 ~]# 

[root@server00 ~]# od -xc /etc/fstab 
... snip ...
0001100    3020    0a0a    2023    6f4e    6e20    7765    696c    656e
              0  \n  \n   #       N   o       n   e   w   l   i   n   e
0001120    6120    2074    4f45    0046
              a   t       E   O   F
0001127
OS / ENVIRONMENT
  • Control Node: Fedora34
  • Managed Node: CentOS Stream release 8
STEPS TO REPRODUCE

Launch playbook [2] to manage /etc/fstab [3]

$ ansible-playbook -i inventory playbook/mount/mount_linux_xfs.yml 

PLAY [linux] *********************************************************************************************************
Tuesday 15 June 2021  22:03:54 +0900 (0:00:00.028)       0:00:00.028 ********** 

TASK [ansible.posix.mount] *******************************************************************************************
changed: [server00]

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

Tuesday 15 June 2021  22:03:55 +0900 (0:00:00.535)       0:00:00.564 ********** 
=============================================================================== 
ansible.posix.mount ------------------------------------------------------------------------------------------- 0.54s
EXPECTED RESULTS

mount succeeded and new mountpoint added to /etc/fstab correctly:

[root@server00 ~]# mount
... snip ...
/dev/vdb1 on /mnt type xfs (rw,relatime,attr2,inode64,noquota)

[root@server00 ~]# cat /etc/fstab 
... snip ...
# No newline at EOF
/dev/vdb1 /mnt xfs defaults 0 0
ACTUAL RESULTS

mount succeeded, but incorrect mountpoint was added to /etc/fstab:

... snip ...
# No newline at EOF/dev/vdb1 /mnt xfs defaults 0 0
@saito-hideki saito-hideki added bug This issue/PR relates to a bug. has_pr verified This issue has been verified/reproduced by maintainer labels Jul 28, 2021
ansible-zuul bot added a commit that referenced this issue Sep 27, 2021
mount - add a newline at the end of line in fstab

SUMMARY
Modify mount module to add a newline at the end of line in /etc/fstab.
Fixes #210
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.mount

ADDITIONAL INFORMATION
None

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: quidame <None>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug. has_pr verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant