Sunday, April 7, 2024

How to mount the nfs share in all the hosts.

--- - name: Mount the NFS share hosts: all become: true vars: mynfs: "172.2.0.200:/nfs/data" mountpoint: "/share" permission: '0777' myopts: 'rw,sync' tasks: - name: utility present redhat-like ansible.builtin.yum: name: - nfs-utils - nfs4-acl-tools state: present when: ansible_os_family == 'RedHat' - name: utility present debian-like ansible.builtin.apt: name: - nfs-common - nfs4-acl-tools state: present when: ansible_os_family == 'Debian' - name: check mountpoint exist ansible.builtin.file: path: "{{ mountpoint }}" state: directory mode: "{{ permission }}" owner: root group: root - name: mount network share ansible.posix.mount: src: "{{ mynfs }}" path: "{{ mountpoint }}" fstype: nfs opts: "{{ myopts }}" state: mounted

No comments:

Post a Comment