I need to mount a smb share to have access on large, shared installation files in Ansible. This works using CLI:
- name: Mount share
become: yes
shell: "mount.cifs {{ smb_share.path }} {{ smb_share.mount_point }} -o user={{ smb_share.user }},password={{ smb_share.password }},mfsymlinks,exec"
However, this has two disadvantages:
- Doesn't follow best practices of using modules instead of shell commands when required
- No detection if already mounted - I'd need to implement this, e.g. by grep for the mountpoint in
mount
There is a mount
module in Ansible. But since this share ist just for installation and uses credentials, I don't want to have it permanently mounted. The boot
parameter looks what I need, sadly not for Linux:
Determines if the filesystem should be mounted on boot.
Only applies to Solaris systems.
I still tried to set boot: no
but as described in the docs, it still creates an /etc/fstab
entry with the plain text password.
Is there any alternative to have a Windows share temprorarily mounted on CentOS 7 with any Ansible module?