salt/states/systems/core/mount/init.sls

101 lines
2.7 KiB
Text

{%- if pillar['mount'] is defined -%}
{%- if pillar['mount']['ext4'] is defined -%}
{%- for mount in pillar['mount']['ext4'] -%}
{%- set device=pillar['mount']['ext4'][mount]['device'] -%}
{{ mount }}:
mount.mounted:
- device: {{ device }}
- fstype: ext4
- mkmnt: True
- opts: rw,relatime,data=ordered
- hidden_opts: rw,relatime,data=ordered
- dump: 0
- pass_num: 2
- persist: True
{%- endfor -%}
{% endif %}
{%- if pillar['mount']['sshfs'] is defined %}
fuse2:
pkg.installed
sshfs:
pkg.installed
fuse-module:
kmod.present:
- name: fuse
- persist: true
mount_host.actcur.com:
ssh_known_hosts.present:
- name: host.actcur.com
- hash_known_hosts: False
- user: root
- enc: ecdsa-sha2-nistp256
- key: "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCnvAIi9HiYDsQCHPWPQrgdLTANveZ3K9v1+0iJDA2yEo67EfkFl7O9Go/pVkOoSjV+eWKQ9A7Az7aMY1tc9ur0="
{% for mount in pillar['mount']['sshfs'] %}
{%- if pillar['mount']['sshfs'][mount]['user'] is defined -%}
{%- set user=pillar['mount']['sshfs'][mount]['user'] -%}
{%- else -%}
{%- set user="mount" -%}
{%- endif -%}
{%- set host=pillar['mount']['sshfs'][mount]['host'] -%}
{%- set dir=pillar['mount']['sshfs'][mount]['directory'] %}
{{ mount }}_key:
file.managed:
- name: /root/.ssh/{{user}}_key
- source: salt://systems/core/mount/keys/{{user}}_key
- user: root
- group: root
- 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
{%- endfor -%}
{% endif %}
{%- if pillar['mount']['nfs'] is defined -%}
nfs-utils:
pkg.installed
rpcbind:
service.running:
- enable: true
nfs-client.target:
service.running:
- enable: true
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'] %}
{{ 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
{%- endfor -%}
{% endif %}
{%- endif -%}