title: Detect and mount filesystem in Ansible
body: <p>I am new to ansible and try to detect a filesystem and than mount if present. I have gone through below links :-</p>
  
  <pre><code>1. https://docs.ansible.com/ansible/latest/modules/filesystem_module.html
  2. https://docs.ansible.com/ansible/latest/modules/mount_module.html
  </code></pre>
  
  <p>I have attached a hard drive manually which is detected by command <strong>fdisk -l</strong> as "/dev/sdb". I want ansible code to detect and mount this filesystem on some location. While running the code "<strong>df -h</strong>" 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. </p>
  
  <p>Code Snippet:</p>
  
  <pre><code>    - 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
  </code></pre>
  
  <p>Thanks in advance and any help would be appreciated.</p>