Autofs mounter

This role will automatically mount a specific network share in a specific mountpoint on the target device.

General

This Role fullfills the following steps:

  • Install autofs service
  - name: Install autofs service
    apt:
      name: autofs
      state: present
  • Install cifs-utils
  - name: Install cifs-utils
    apt:
      name: cifs-utils
      state: present
  • Create the mountpoint
  - name: Create Scratch directory
    file:
      path: "{{ scratch_mnt }}"
      state: directory
  • Copy template auto.master from templates to /etc
  - name: Copy auto.master file
    template:
      src: auto.master
      dest: /etc/auto.master
      force: true
  • Copy template auto.software from templates to /etc
  - name: Copy auto.software file
    template:
      src: auto.software
      dest: /etc/auto.software
      force: true
  • Restart AutoFS Service
  - name: Restart autofs service
    service:
      name: autofs
      state: restarted
    become: true

Dependencies

Role Dependencies

None

Package Dependencies

None

Role Variables

Name Type Default value Purpose Comment Role
autofs_is_enabled Boolean false If this variable is set to true in the inventory file, Ansible will run the role

Has to be defined in hosts file
Possible values:
true: enables role
false: disables role
jammy_autofs
scratch_mnt String - This variable defines the mountpoint on the target system.

Doesn't have to be already existing

Has to be defined in hosts file
Example:

/mnt/groupshare: Sets mountpoint to /mnt/groupshare
jammy_autofs
scratch_path String - This variable defines the target share, which has to be mounted on the device

Has to be defined in hosts file
Example:

//SERVERNAME/sharename/: Mounts //SERVERNAME/sharename on target device
jammy_autofs
scratch_protocol String - This variable defines the protocol that should be used

Has to be defined in hosts file
Possible values:

nfs:
Use NFS protocol for mounting the share
cifs:
Use CIFS protocol for mounting the share
jammy_autofs

Example Playbook

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

---
- hosts: all
  roles:
  - jammy_autofs

Example Inventory/hosts

COMPUTERNAME:
  mac_address: aa-bb-cc-dd-ee-ff
  autofs_is_enabled: true
  scratch_mnt: /mnt/groupshare
  scratch_path: //SERVERNAME/sharename
  scratch_protocol: cifs

License

BSD

Author Information

Maintainer:
Sandro Romagnoli

Support-Contact:
s4d-linux-support@id.ethz.ch