From 682377a503bec9896ebf6b596a8ce29ac7d1b0af Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sun, 7 Feb 2021 08:03:13 -0600 Subject: [PATCH] Test SSHFS so that bad FSTAB entries don't get created on Linux when they'll break. --- facts/general/service.yml | 2 +- tasks/general/acct_mgmt/mounts.yml | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/facts/general/service.yml b/facts/general/service.yml index c903ad9..c7bfb61 100644 --- a/facts/general/service.yml +++ b/facts/general/service.yml @@ -16,5 +16,5 @@ cups_pattern: cupsd cups_browse: cups-browsed cups_browse_pattern: cups-browsed - sshfs_leet_cmd: "sshfs {{ leet_ssh }}: /mnt/leet -o allow_other,_netdev" + sshfs_leet_cmd: "sshfs {{ leet_ssh }}: /mnt/leet -o defaults,allow_other,_netdev" when: ansible_system == "FreeBSD" \ No newline at end of file diff --git a/tasks/general/acct_mgmt/mounts.yml b/tasks/general/acct_mgmt/mounts.yml index 64bafaf..78d1425 100644 --- a/tasks/general/acct_mgmt/mounts.yml +++ b/tasks/general/acct_mgmt/mounts.yml @@ -1,11 +1,16 @@ --- # Mount shares that all systems should have. +- name: General | Account Management | Mounts | Test SSHFS + shell: "sshfs ling@leet: /mnt/leet -o allow_other,nonempty" + register: sshfs_works + - name: General | Account Management | Mounts | Create 1337 Folder file: path: "{{ leet_drive }}" state: directory mode: '0755' + when: sshfs_works #TODO Remove this @@ -28,7 +33,7 @@ backup: yes when: ansible_system == "Linux" -# Linux uses fstab +#TODO Remove this - name: General | Account Management | Mounts | Create 1337 fstab Entry blockinfile: path: /etc/fstab @@ -39,11 +44,23 @@ backup: yes when: ansible_system == "Linux" + +# Linux uses fstab +- name: General | Account Management | Mounts | Create 1337 fstab Entry + blockinfile: + path: /etc/fstab + block: | + {{ leet_ssh }}: /mnt/leet fuse.sshfs defaults,_netdev,allow_other 0 0 + marker: '# {mark} MANAGED BY ANSIBLE | 1337 Share' + state: present + backup: yes + when: ansible_system == "Linux" and sshfs_works + - name: General | Account Management | Mounts | Mount All (Linux) shell: mount -a args: warn: false - when: ansible_system == "Linux" + when: ansible_system == "Linux" and sshfs_works # FreeBSD has to do this via root cron job, fstab is unhappy @@ -51,9 +68,9 @@ shell: umount -f /mnt/leet args: warn: false - when: ansible_system == "FreeBSD" + when: ansible_system == "FreeBSD" and sshfs_works ignore_errors: yes - name: General | Account Management | Mounts | Remount 1337 (FreeBSD) shell: "{{ sshfs_leet_cmd }}" - when: ansible_system == "FreeBSD" \ No newline at end of file + when: ansible_system == "FreeBSD" and sshfs_works \ No newline at end of file