80 lines
2.4 KiB
YAML
Raw Normal View History

---
# Mount shares that all systems should have.
# Test if this machine can use SSHFS
- name: General | Account Management | Mounts | Create Test Folder
file:
path: "/mnt/test"
state: directory
mode: '0755'
when: not leet_drive_details.stat.exists
- name: General | Account Management | Mounts | Test SSHFS
2021-02-07 15:19:33 -06:00
shell: "sshfs {{ leet_ssh }}: /mnt/test -o allow_other"
2021-02-07 08:11:28 -06:00
register: sshfs_test
ignore_errors: yes
when: not leet_drive_details.stat.exists
2021-02-11 12:22:42 -06:00
- name: General | Account Management | Mounts | SSHFS Already Working
shell: "echo SUCCESS"
register: sshfs_test
when: leet_drive_details.stat.exists
2021-02-13 05:40:46 -06:00
# Make super sure that the failed key exists.
2021-02-13 05:46:51 -06:00
# https://www.middlewareinventory.com/blog/ansible-dict/
2021-02-13 05:40:46 -06:00
- name: General | Account Management | Mounts | Check/Set sshfs_test.failed Key
set_fact:
2021-02-13 05:45:21 -06:00
sshfs_test: "{{ sshfs_test | combine({item.key : item.value}) }}"
2021-02-13 05:44:03 -06:00
with_items:
- { 'key': 'failed', 'value': false }
2021-02-13 05:40:46 -06:00
when: sshfs_test.failed is not defined
- debug:
var: sshfs_test
2021-02-07 09:05:57 -06:00
2021-02-07 08:08:43 -06:00
# Begin setting up 1337
2021-02-02 21:28:17 -06:00
- name: General | Account Management | Mounts | Create 1337 Folder
2021-02-01 08:17:50 -06:00
file:
path: "{{ leet_drive }}"
2021-02-01 08:17:50 -06:00
state: directory
mode: '0755'
# 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
2021-02-13 05:40:46 -06:00
when: ansible_system == "Linux" and not sshfs_test.failed
2021-02-06 07:00:47 -06:00
- name: General | Account Management | Mounts | Mount All (Linux)
shell: mount -a
2021-02-02 21:12:44 -06:00
args:
2021-02-02 21:10:56 -06:00
warn: false
2021-02-13 05:46:51 -06:00
when: ansible_system == "Linux" and not sshfs_test.failed
2021-02-03 12:50:29 -06:00
2021-02-06 07:00:47 -06:00
# FreeBSD has to do this via root cron job, fstab is unhappy
- name: General | Account Management | Mounts | Unmount 1337 (FreeBSD)
2021-02-06 07:00:47 -06:00
shell: umount -f /mnt/leet
args:
warn: false
2021-02-07 08:11:28 -06:00
when: ansible_system == "FreeBSD" and not sshfs_test.failed
2021-02-06 07:00:47 -06:00
ignore_errors: yes
- name: General | Account Management | Mounts | Remount 1337 (FreeBSD)
2021-02-06 07:00:47 -06:00
shell: "{{ sshfs_leet_cmd }}"
2021-02-13 05:40:46 -06:00
when: ansible_system == "FreeBSD" and not sshfs_test.failed
# Ensure correct cron jobs and other downstream dependencies are done properly.
- name: General | Account Management | Mounts | Refresh Variable leet_drive_details
stat:
path: "{{ leet_drive }}/Temp/ansible"
register: leet_drive_details