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 checkout dev;
git reset --hard master; git reset --hard master;
git push --force; git push --force;
git reset --hard origin/dev

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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