1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/usb_lib/tasks/main.yml

110 lines
3.6 KiB
YAML
Raw Normal View History

2020-01-30 09:00:00 +00:00
# TO DO:
# - validate input vars + prereqs
# - move 6 top stanzas into install.yml
# - move 6 mid/lower stanzas into enable-or-disable.yml
# - verify analogous NGINX logic from roles/nginx/* -- then integrate as nec?
2018-10-31 04:20:01 +00:00
- name: Add dir {{ doc_root }}/local_content, where USB drive links can appear
file:
state: directory
2020-01-30 09:00:00 +00:00
path: "{{ doc_root }}/local_content"
owner: "{{ apache_user }}"
2018-10-15 08:06:01 +00:00
group: "{{ iiab_admin_user }}" # ISN'T "{{ apache_user }}" MORE APPROPRIATE?
2020-01-30 09:00:00 +00:00
mode: '0775'
2017-05-27 18:09:50 +00:00
2020-01-30 09:00:00 +00:00
- name: 'Install from template: /etc/udev/rules.d/usbmount.rules, /etc/systemd/system/usbmount@.service, /usr/bin/iiab-usb_lib-show-all-on, /usr/bin/iiab-usb_lib-show-all-off'
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
2018-03-13 19:06:12 +00:00
mode: "{{ item.mode }}"
with_items:
2018-03-13 19:06:12 +00:00
- { src: 'usbmount@.service.j2' , dest: '/etc/systemd/system/usbmount@.service', mode: '0644' }
- { src: 'usbmount.rules.j2' , dest: '/etc/udev/rules.d/usbmount.rules', mode: '0644' }
2020-01-30 09:00:00 +00:00
- { src: 'iiab-usb_lib-show-all-on' , dest: '/usr/bin/', mode: '0755' }
- { src: 'iiab-usb_lib-show-all-off' , dest: '/usr/bin/', mode: '0755' }
2018-10-31 04:20:01 +00:00
- name: Enable exFAT and NTFS in /etc/usbmount/usbmount.conf
2020-01-30 09:00:00 +00:00
lineinfile:
2018-02-15 00:47:38 +00:00
regexp: '^FILESYSTEMS.*'
line: 'FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus exfat fuseblk ntfs"'
2018-10-31 04:20:01 +00:00
path: /etc/usbmount/usbmount.conf
2018-02-15 00:47:38 +00:00
2020-01-30 09:00:00 +00:00
- name: Install /etc/{{ apache_conf_dir }}/content_dir.conf from template
template:
src: content_dir.conf
dest: "/etc/{{ apache_conf_dir }}"
when: apache_install
# RECORD usb_lib AS INSTALLED
- name: "Set 'usb_lib_installed: True'"
set_fact:
usb_lib_installed: True
- name: "Add 'usb_lib_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2020-01-30 09:00:00 +00:00
regexp: '^usb_lib_installed'
line: 'usb_lib_installed: True'
- name: Install /etc/usbmount/mount.d/70-usb-library from template, if usb_lib_enabled
template:
src: mount.d/70-usb-library
dest: /etc/usbmount/mount.d/
owner: root
group: root
mode: '0751'
when: usb_lib_enabled | bool
- name: Install /etc/usbmount/umount.d/70-usb-library from template, if usb_lib_enabled
template:
src: umount.d/70-usb-library
dest: /etc/usbmount/umount.d
owner: root
group: root
2020-01-30 09:00:00 +00:00
mode: '0751'
when: usb_lib_enabled | bool
2017-05-27 18:09:50 +00:00
2018-10-31 04:20:01 +00:00
- name: Remove /etc/usbmount/mount.d/70-usb-library if not usb_lib_enabled
file:
path: /etc/usbmount/mount.d/70-usb-library
state: absent
2017-05-27 18:09:50 +00:00
when: not usb_lib_enabled
2018-10-31 04:20:01 +00:00
- name: Remove /etc/usbmount/umount.d/70-usb-library if not usb_lib_enabled
file:
path: /etc/usbmount/umount.d/70-usb-library
state: absent
2017-05-27 18:09:50 +00:00
when: not usb_lib_enabled
2020-01-30 09:00:00 +00:00
- name: Enable http://box/usb via Apache, if usb_lib_enabled
command: a2ensite content_dir.conf
when: apache_install and usb_lib_enabled
- name: Disable http://box/usb via Apache, if not usb_lib_enabled
command: a2dissite content_dir.conf
when: apache_install and not usb_lib_enabled
2018-07-19 03:25:32 +00:00
- name: Put variable in iiab.env that enables display of content at root of USB
lineinfile:
2018-10-31 04:20:01 +00:00
path: "{{ iiab_env_file }}"
regexp: "^IIAB_USB_LIB_SHOW_ALL.*"
line: "IIAB_USB_LIB_SHOW_ALL={{ iiab_usb_lib_show_all }}"
2020-01-30 09:00:00 +00:00
- name: Add 'usb_lib' variable values to {{ iiab_ini_file }}
ini_file:
2018-10-31 04:43:24 +00:00
path: "{{ iiab_ini_file }}"
2020-01-30 09:00:00 +00:00
section: usb_lib
option: "{{ item.option }}"
value: "{{ item.value | string }}"
2017-05-27 18:09:50 +00:00
with_items:
- option: name
2020-01-30 09:00:00 +00:00
value: usb_lib
2017-05-27 18:09:50 +00:00
- option: description
2020-01-30 09:00:00 +00:00
value: '"usb_lib automounts Teacher Content on USB drives to /library/www/html/local_content, so students can browse it almost immediately at http://box/usb"'
2017-05-27 18:09:50 +00:00
- option: enabled
value: "{{ usb_lib_enabled }}"