AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible mount Module: Manage Filesystem Mounts and fstab (Complete Guide)

By Luca Berton · Published 2024-01-01 · Category: installation

How to use Ansible mount module to mount filesystems, manage fstab entries, NFS mounts, tmpfs. Complete guide with playbook examples for disk management.

Ansible mount Module: Manage Filesystem Mounts and fstab (Complete Guide)

The ansible.builtin.mount module control active and configured mount points. This guide covers all common use cases with practical playbook examples.

Mount a Filesystem

NFS Mount

tmpfs Mount

Add to fstab Without Mounting

Unmount

FAQ

How do I mount a filesystem in Ansible?

Use ansible.builtin.mount with path (mount point), src (device/share), fstype, and state: mounted. This both mounts the filesystem and adds it to /etc/fstab.

What mount states are available?

mounted (mount + fstab), present (fstab only), unmounted (unmount, keep fstab), absent (unmount + remove fstab), remounted (remount with new options).

How do I mount NFS shares with Ansible?

Use mount with fstype: nfs, src: "server:/path", and appropriate opts like rw,sync,hard,intr. Ensure the nfs-common package is installed first.

Conclusion

The ansible.builtin.mount module is a versatile tool for control active and configured mount points. Use the examples above as starting points and adapt them to your infrastructure needs.

Related ArticlesAnsible file Module: Manage DirectoriesAnsible Playbook Guide

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home