I am new to ansible and try to detect a filesystem and than mount if present. I have gone through below links :-
1. https://docs.ansible.com/ansible/latest/modules/filesystem_module.html
2. https://docs.ansible.com/ansible/latest/modules/mount_module.html
I have attached a hard drive manually which is detected by command fdisk -l as "/dev/sdb". I want ansible code to detect and mount this filesystem on some location. While running the code "df -h" is not showing the mounted filesystem and not failing also. And even if I am listing all filesystem or mount point through ansible code, this filesystem (/dev/sdb) is not listing.
Code Snippet:
- name: Create File System
filesystem:
fstype: ext4
dev: "{{ mount_src }}"
- name: Mount File System
mount:
path: "{{ mount_path }}"
src: "{{ mount_src }}"
fstype: ext4
state: mounted
Thanks in advance and any help would be appreciated.