mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Update main.yml
This commit is contained in:
parent
77bb569379
commit
a055bfdcde
1 changed files with 31 additions and 84 deletions
|
@ -1,91 +1,36 @@
|
||||||
# TO DO:
|
# TO DO: (2020-02-13)
|
||||||
# - validate input vars + prereqs
|
# - Look at analogous NGINX logic for http://box/usb in
|
||||||
# - move 6 top stanzas into install.yml
|
# nginx/templates/iiab.conf.j2 and make that visually meaningful for teachers:
|
||||||
# - move 6 mid/lower stanzas into enable-or-disable.yml
|
# https://github.com/iiab/iiab/blob/master/roles/nginx/templates/iiab.conf.j2#L5-L8
|
||||||
# - verify analogous NGINX logic from roles/nginx/* -- then integrate as nec?
|
|
||||||
|
|
||||||
- name: Add dir {{ doc_root }}/local_content, where USB drive links can appear
|
|
||||||
file:
|
|
||||||
state: directory
|
|
||||||
path: "{{ doc_root }}/local_content"
|
|
||||||
owner: "{{ apache_user }}"
|
|
||||||
group: "{{ iiab_admin_user }}" # ISN'T "{{ apache_user }}" MORE APPROPRIATE?
|
|
||||||
mode: '0775'
|
|
||||||
|
|
||||||
- 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 }}"
|
|
||||||
mode: "{{ item.mode }}"
|
|
||||||
with_items:
|
|
||||||
- { 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' }
|
|
||||||
- { src: 'iiab-usb_lib-show-all-on' , dest: '/usr/bin/', mode: '0755' }
|
|
||||||
- { src: 'iiab-usb_lib-show-all-off' , dest: '/usr/bin/', mode: '0755' }
|
|
||||||
|
|
||||||
- name: Enable exFAT and NTFS in /etc/usbmount/usbmount.conf
|
|
||||||
lineinfile:
|
|
||||||
regexp: '^FILESYSTEMS.*'
|
|
||||||
line: 'FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus exfat fuseblk ntfs"'
|
|
||||||
path: /etc/usbmount/usbmount.conf
|
|
||||||
|
|
||||||
- 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
|
# "How do i fail a task in Ansible if the variable contains a boolean value?
|
||||||
|
# I want to perform input validation for Ansible playbooks"
|
||||||
|
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
|
||||||
|
|
||||||
- name: "Set 'usb_lib_installed: True'"
|
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
|
||||||
set_fact:
|
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
|
||||||
usb_lib_installed: True
|
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
|
||||||
|
|
||||||
- name: "Add 'usb_lib_installed: True' to {{ iiab_state_file }}"
|
- name: Assert that "usb_lib_install is sameas true" (boolean not string etc)
|
||||||
lineinfile:
|
assert:
|
||||||
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
that: usb_lib_install is sameas true
|
||||||
regexp: '^usb_lib_installed'
|
fail_msg: "PLEASE SET 'usb_lib_install: True' e.g. IN: /etc/iiab/local_vars.yml"
|
||||||
line: 'usb_lib_installed: True'
|
quiet: yes
|
||||||
|
|
||||||
|
- name: Assert that "usb_lib_enabled | type_debug == 'bool'" (boolean not string etc)
|
||||||
|
assert:
|
||||||
|
that: usb_lib_enabled | type_debug == 'bool'
|
||||||
|
fail_msg: "PLEASE GIVE VARIABLE 'usb_lib_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
|
||||||
|
quiet: yes
|
||||||
|
|
||||||
|
|
||||||
- name: Install /etc/usbmount/mount.d/70-usb-library from template, if usb_lib_enabled
|
- name: Install USB_LIB if 'usb_lib_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
|
||||||
template:
|
include_tasks: install.yml
|
||||||
src: mount.d/70-usb-library
|
when: usb_lib_installed is undefined
|
||||||
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
|
|
||||||
mode: '0751'
|
|
||||||
when: usb_lib_enabled | bool
|
|
||||||
|
|
||||||
- name: Remove /etc/usbmount/mount.d/70-usb-library if not usb_lib_enabled
|
- include_tasks: enable-or-disable.yml
|
||||||
file:
|
|
||||||
path: /etc/usbmount/mount.d/70-usb-library
|
|
||||||
state: absent
|
|
||||||
when: not usb_lib_enabled
|
|
||||||
|
|
||||||
- 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
|
|
||||||
when: not usb_lib_enabled
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
|
|
||||||
- name: Put variable in iiab.env that enables display of content at root of USB
|
- name: Put variable in iiab.env that enables display of content at root of USB
|
||||||
|
@ -96,14 +41,16 @@
|
||||||
|
|
||||||
- name: Add 'usb_lib' variable values to {{ iiab_ini_file }}
|
- name: Add 'usb_lib' variable values to {{ iiab_ini_file }}
|
||||||
ini_file:
|
ini_file:
|
||||||
path: "{{ iiab_ini_file }}"
|
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||||
section: usb_lib
|
section: usb_lib
|
||||||
option: "{{ item.option }}"
|
option: "{{ item.option }}"
|
||||||
value: "{{ item.value | string }}"
|
value: "{{ item.value | string }}"
|
||||||
with_items:
|
with_items:
|
||||||
- option: name
|
- option: name
|
||||||
value: usb_lib
|
value: USB_LIB
|
||||||
- option: description
|
- option: description
|
||||||
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"'
|
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"'
|
||||||
- option: enabled
|
- option: usb_lib_install
|
||||||
|
value: "{{ usb_lib_install }}"
|
||||||
|
- option: usb_lib_enabled
|
||||||
value: "{{ usb_lib_enabled }}"
|
value: "{{ usb_lib_enabled }}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue