Moved to autofs for sshfs and nfs

This commit is contained in:
Beth Parker 2017-09-28 11:34:36 -05:00
parent 7ecb1bae36
commit 6d370e3104
12 changed files with 91 additions and 28 deletions

View file

@ -16,3 +16,4 @@ git push;
git checkout dev;
git reset --hard master;
git push --force;
git reset --hard origin/dev

View file

@ -1,6 +1,7 @@
mount:
sshfs:
/mnt/video:
name: video
host: host.actcur.com
directory: /mnt/butter/video
user: mount

View file

@ -1,6 +1,7 @@
mount:
sshfs:
/mnt/repos:
name: repos
host: host.actcur.com
directory: /mnt/butter/repos
user: gitlab

View file

@ -1,6 +1,7 @@
mount:
sshfs:
/mnt/pkgs:
name: pkgs
host: host.actcur.com
directory: /mnt/butter/pkgs
user: pkgs

View file

@ -1,14 +1,15 @@
mount:
sshfs:
/mnt/video:
name: video
host: host.actcur.com
directory: /mnt/butter/video
user: mount
/mnt/music:
name: music
host: host.actcur.com
directory: /mnt/butter/music
user: mount
ext4:
/var/lib/plexmediaserver/Library:
device: UUID=0ab3f7fc-6525-40ba-905c-ff5fff2de1a3

View file

@ -1,6 +1,7 @@
mount:
sshfs:
/mnt/video:
name: video
host: host.actcur.com
directory: /mnt/butter/video
user: mount

View file

@ -1,10 +1,12 @@
mount:
sshfs:
/mnt/backups:
name: backups
host: host.actcur.com
directory: /mnt/butter/backups/configurations
user: backups
/secure/ca/:
/secure/ca:
name: ca
host: ca.actcur.com
directory: /etc/easy-rsa/pki/
user: ca

View file

@ -1,6 +1,7 @@
mount:
sshfs:
/mnt/video:
name: video
host: host.actcur.com
directory: /mnt/butter/video
user: mount

View file

@ -0,0 +1,2 @@
/mnt/autofs/ssh /etc/autofs/auto.ssh
/mnt/autofs/nfs /etc/autofs/auto.nfs

View file

@ -0,0 +1,8 @@
{%- if nfs is defined -%}
{% for mount in nfs -%}
{%- set host=nfs[mount]['host'] -%}
{%- set dir=nfs[mount]['directory'] %}
{%- set name=nfs[mount]['name'] %}
{{name}} -rw,soft,intr,rsize=8192,wsize=8192 {{host}}:{{dir}}
{%- endfor -%}
{% endif %}

View file

@ -0,0 +1,13 @@
{%- if sshfs is defined -%}
{% for mount in sshfs -%}
{%- if sshfs[mount]['user'] is defined -%}
{%- set user=sshfs[mount]['user'] -%}
{%- else -%}
{%- set user="mount" -%}
{%- endif -%}
{%- set host=sshfs[mount]['host'] -%}
{%- set dir=sshfs[mount]['directory'] %}
{%- set name=sshfs[mount]['name'] %}
{{name}} -fstype=fuse,rw,allow_other,idmap=user,IdentityFile=/root/.ssh/{{user}}_key :sshfs\#{{user}}@{{host}}\:{{dir}}
{%- endfor -%}
{% endif %}

View file

@ -16,6 +16,27 @@
{%- endfor -%}
{% endif %}
autofs-pkg:
pkg.installed:
- name: autofs
service.running:
- name: autofs
- watch:
- file: /etc/autofs/auto.master
{%- if pillar['mount']['sshfs'] is defined %}
- file: /etc/autofs/auto.ssh
{% endif -%}
{%- if pillar['mount']['nfs'] is defined %}
- file: /etc/autofs/auto.nfs
{% endif %}
autofs-master:
file.managed:
- name: /etc/autofs/auto.master
- source: salt://systems/core/mount/auto.master
- user: root
- group: root
- mode: 644
{%- if pillar['mount']['sshfs'] is defined %}
fuse2:
@ -26,6 +47,17 @@ fuse-module:
kmod.present:
- name: fuse
- persist: true
/etc/autofs/auto.ssh:
file.managed:
- source: salt://systems/core/mount/auto.ssh
- user: root
- group: root
- mode: 644
- template: jinja
- context:
sshfs: {{pillar['mount']['sshfs']}}
mount_host.actcur.com:
ssh_known_hosts.present:
- name: host.actcur.com
@ -40,8 +72,7 @@ mount_host.actcur.com:
{%- else -%}
{%- set user="mount" -%}
{%- endif -%}
{%- set host=pillar['mount']['sshfs'][mount]['host'] -%}
{%- set dir=pillar['mount']['sshfs'][mount]['directory'] %}
{%- set name=pillar['mount']['sshfs'][mount]['name'] %}
{{ mount }}_key:
file.managed:
- name: /root/.ssh/{{user}}_key
@ -51,17 +82,12 @@ mount_host.actcur.com:
- mode: 600
- makedirs: true
{{ mount }}:
file.directory: []
mount.mounted:
- device: {{user}}@{{host}}:{{dir}}
- fstype: fuse.sshfs
- mkmnt: True
- opts: allow_other,user,IdentityFile=/root/.ssh/{{user}}_key,delay_connect,x-systemd.automount,_netdev,idmap=user,reconnect
- hidden_opts: allow_other,user,IdentityFile=/root/.ssh/{{user}}_key,delay_connect,x-systemd.automount,_netdev,idmap=user,reconnect
- dump: 0
- pass_num: 2
- persist: True
{{ mount }}_link:
file.symlink:
- name: {{ mount }}
- target: /mnt/autofs/ssh/{{name}}
- force: true
- makedirs: true
{%- endfor -%}
{% endif %}
@ -81,20 +107,25 @@ remote-fs.target:
service.running:
- enable: true
{% for mount in pillar['mount']['nfs'] %}
{%- set host=pillar['mount']['nfs'][mount]['host'] -%}
{%- set dir=pillar['mount']['nfs'][mount]['directory'] %}
/etc/autofs/auto.nfs:
file.managed:
- source: salt://systems/core/mount/auto.nfs
- user: root
- group: root
- mode: 644
- template: jinja
- context:
nfs: {{pillar['mount']['nfs']}}
{{ mount }}:
mount.mounted:
- device: {{host}}:{{dir}}
- fstype: nfs
- mkmnt: True
- opts: defaults,noauto,,x-systemd.timeout=10,x-systemd.automount
- hidden_opts: defaults,noauto,,x-systemd.timeout=10,x-systemd.automount
- dump: 0
- pass_num: 2
- persist: True
{% for mount in pillar['mount']['nfs'] %}
{%- set name=pillar['mount']['nfs'][mount]['name'] %}
{{ mount }}_link:
file.symlink:
- name: {{ mount }}
- target: /mnt/autofs/ssh/{{name}}
- force: true
- makedirs: true
{%- endfor -%}
{% endif %}