@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=\\neo\tank automount
|
||||
|
||||
[Automount]
|
||||
Where=/mnt/tank
|
||||
TimeoutIdleSec=300
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,38 @@
|
||||
- name: Install cifs-utils
|
||||
ansible.builtin.apt:
|
||||
name: cifs-utils
|
||||
update_cache: true
|
||||
state: present
|
||||
|
||||
- name: Lookup user name
|
||||
ansible.builtin.set_fact:
|
||||
network_shares_user_name: "{{ lookup('env', 'USER') }}"
|
||||
|
||||
- name: Get user passwd info for {{ network_shares_user_name }}
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
key: "{{ network_shares_user_name }}"
|
||||
|
||||
- name: Extract user id and gid
|
||||
ansible.builtin.set_fact:
|
||||
network_shares_user_id: "{{ ansible_facts.getent_passwd[network_shares_user_name].1 }}"
|
||||
network_shares_user_gid: "{{ ansible_facts.getent_passwd[network_shares_user_name].2 }}"
|
||||
|
||||
- name: Copy mount file
|
||||
ansible.builtin.template:
|
||||
src: mnt-tank.mount.j2
|
||||
dest: /etc/systemd/system/mnt-tank.mount
|
||||
mode: "0644"
|
||||
|
||||
- name: Copy automount file
|
||||
ansible.builtin.copy:
|
||||
src: mnt-tank.automount
|
||||
dest: /etc/systemd/system/mnt-tank.automount
|
||||
mode: "0644"
|
||||
|
||||
- name: Enable automount
|
||||
ansible.builtin.systemd_service:
|
||||
name: mnt-tank.automount
|
||||
enabled: true
|
||||
daemon-reload: true
|
||||
state: started
|
||||
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=\\neo\tank mount
|
||||
|
||||
[Mount]
|
||||
What=//192.168.0.200/tank
|
||||
Where=/mnt/tank
|
||||
Type=cifs
|
||||
Options=guest,uid={{ network_shares_user_id }},gid={{ network_shares_user_gid }},iocharset=utf8,ro
|
||||
LazyUnmount=true
|
||||
TimeoutSec=10
|
||||
Reference in New Issue
Block a user