2020-03-08 19:26:05 +00:00
# Role "www_base" runs earlier, likely in 3-BASE-SERVER.
# Role "www_options" runs here, probably in 4-SERVER-OPTIONS.
2020-02-13 01:53:36 +00:00
# HOMEPAGE
- name : Create dir {{ doc_root }}{{ iiab_home_url }} just in case variable iiab_home_url was customized. (Standard path {{doc_root}}/home was created earlier.)
file :
state : directory
path : "{{ doc_root }}{{ iiab_home_url }}" # /library/www/html/home
owner : "{{ apache_user }}"
group : "{{ apache_user }}"
mode : '0755'
2020-02-14 03:53:19 +00:00
# Used to be run by httpd/tasks/install.yml
2020-02-13 01:53:36 +00:00
- name : "IN CASE NGINX IS DISABLED: Enable IIAB pages via Apache (e.g. on port 80) if apache_install"
include_tasks : roles/httpd/tasks/homepage.yml
2020-05-17 02:48:52 +00:00
when : apache_installed is defined
2020-02-13 01:53:36 +00:00
2020-02-14 03:53:19 +00:00
# Used to be run by nginx/tasks/install.yml
2020-02-13 01:53:36 +00:00
- name : Enable IIAB pages via NGINX (e.g. on port 80) if nginx_install
include_tasks : roles/nginx/tasks/homepage.yml
2020-05-17 02:48:52 +00:00
when : nginx_installed is defined
2020-10-16 20:46:19 +00:00
#when: nginx_install
2020-02-13 01:53:36 +00:00
2020-10-31 23:05:37 +00:00
- name : Make home page autostart on localhost (the server's console) if session manager is LXDE (rpi)
stat :
2022-05-23 23:51:01 +00:00
path : /etc/xdg/lxsession/LXDE-pi/autostart
2020-10-31 23:05:37 +00:00
register : lxde_present
2020-11-03 04:14:18 +00:00
- name : Check for Chromium name change
stat :
2022-05-23 23:51:01 +00:00
path : /usr/bin/chromium
2020-11-03 04:14:18 +00:00
register : chromium_present
2020-11-03 12:03:10 +00:00
- name : Add chromium-browser to /etc/xdg/lxsession/LXDE-pi/autostart if session manager is LXDE
2020-10-31 23:05:37 +00:00
lineinfile :
2022-05-23 23:51:01 +00:00
path : /etc/xdg/lxsession/LXDE-pi/autostart
regexp : '^/usr/bin/chromium-browser'
line : '/usr/bin/chromium-browser --disable-restore-session-state http://box/home'
when : lxde_present.stat.exists and not chromium_present.stat.exists
2020-11-03 04:14:18 +00:00
2020-11-03 12:03:10 +00:00
- name : Add chromium to /etc/xdg/lxsession/LXDE-pi/autostart if session manager is LXDE
2020-11-03 04:14:18 +00:00
lineinfile :
2022-05-23 23:51:01 +00:00
path : /etc/xdg/lxsession/LXDE-pi/autostart
regexp : '^/usr/bin/chromium'
line : '/usr/bin/chromium --disable-restore-session-state http://box/home'
when : lxde_present.stat.exists and chromium_present.stat.exists
2020-10-31 23:05:37 +00:00
2021-06-28 21:59:28 +00:00
2020-03-08 18:34:55 +00:00
- debug :
2021-06-28 17:29:58 +00:00
msg: 'THE 5 ANSIBLE STANZAS BELOW ONLY RUN... when : moodle_install or nextcloud_install or pbx_install or wordpress_install'
2020-02-13 01:53:36 +00:00
2021-06-28 17:29:58 +00:00
- block : # 5-STANZA BLOCK BEGINS
2020-02-16 07:47:45 +00:00
2021-06-27 20:01:53 +00:00
# roles/nginx has installed pkg 'php{{ php_version }}-fpm' in 3-base-server
2020-02-16 07:47:45 +00:00
2021-05-22 21:23:00 +00:00
- name : "Enact 'nginx_high_php_limits: False' in /etc/php/{{ php_version }}/fpm/php.ini for lightweight use of WordPress/Nextcloud/PBX (allow photos/docs up to 100MB, 100s timeouts, with 2 PHP system defaults: memory_limit = 128M, max_input_vars = 1000)"
2020-03-07 07:32:41 +00:00
lineinfile :
2021-06-28 21:59:28 +00:00
path : /etc/php/{{ php_version }}/fpm/php.ini # COMPARE /etc/php/{{ php_version }}/cli/php.ini AND /etc/php/{{ php_version }}/apache2/php.ini
regexp : "{{ item.regexp }}"
line : "{{ item.line }}"
with_items :
- { regexp: '^upload_max_filesize', line : 'upload_max_filesize = 100M ; default is 2M' }
- { regexp: '^post_max_size', line : 'post_max_size = 100M ; default is 8M' }
- { regexp: '^max_execution_time', line : 'max_execution_time = 100 ; default is 30' }
- { regexp: '^max_input_time', line : 'max_input_time = 100 ; default is 60' }
- { regexp: '^memory_limit', line : 'memory_limit = 128M ; default is 128M / Nextcloud requests 512M' }
- { regexp: '^max_input_vars', line : 'max_input_vars = 1000 ; default is 1000 / Moodle 3.11+ requires 5000+ with PHP 8+' }
when: not nginx_high_php_limits and not moodle_install # REMINDER: THIS ENTIRE 5-STANZA BLOCK IS ONLY INVOKED... when : moodle_install or nextcloud_install or pbx_install or wordpress_install
- name : "Enact 'nginx_high_php_limits: False' in /etc/php/{{ php_version }}/cli/php.ini for lightweight use of WordPress/Nextcloud/PBX (allow photos/docs up to 100MB, 100s timeouts, with 2 PHP system defaults: memory_limit = 128M, max_input_vars = 1000)"
lineinfile :
path : /etc/php/{{ php_version }}/cli/php.ini # COMPARE /etc/php/{{ php_version }}/fpm/php.ini AND /etc/php/{{ php_version }}/apache2/php.ini
2020-03-07 07:32:41 +00:00
regexp : "{{ item.regexp }}"
line : "{{ item.line }}"
with_items :
- { regexp: '^upload_max_filesize', line : 'upload_max_filesize = 100M ; default is 2M' }
- { regexp: '^post_max_size', line : 'post_max_size = 100M ; default is 8M' }
2020-03-08 18:34:55 +00:00
- { regexp: '^max_execution_time', line : 'max_execution_time = 100 ; default is 30' }
- { regexp: '^max_input_time', line : 'max_input_time = 100 ; default is 60' }
2020-03-07 07:32:41 +00:00
- { regexp: '^memory_limit', line : 'memory_limit = 128M ; default is 128M / Nextcloud requests 512M' }
2021-06-28 21:59:28 +00:00
- { regexp: '^max_input_vars', line : 'max_input_vars = 1000 ; default is 1000 / Moodle 3.11+ requires 5000+ with PHP 8+' }
2021-06-28 17:29:58 +00:00
when: not nginx_high_php_limits and not moodle_install # REMINDER: THIS ENTIRE 5-STANZA BLOCK IS ONLY INVOKED... when : moodle_install or nextcloud_install or pbx_install or wordpress_install
2020-03-07 07:32:41 +00:00
2021-08-04 11:47:33 +00:00
# WARNING: This might cause excess use of RAM/disk or other resources!
# The first 5 values below were chosen by @ericnitschke and @kananigit on
# 2018-09-19: https://github.com/iiab/iiab/issues/1147
2021-06-28 21:59:28 +00:00
# 2020-03-08: IIAB DOES NOT SUPPORT UNINSTALLING APPS, so additional
# clauses (to reset/restore PHP's defaults) are not necessary at this time.
2020-03-08 18:34:55 +00:00
2021-06-28 21:59:28 +00:00
# 2021-06-28: WITH PHP 8, MOODLE'S CLI INSTALLER UNFORTUNATELY *REQUIRES*
2021-08-04 00:26:28 +00:00
# editing /etc/php/{{ php_version }}/cli/php.ini (below) -- though during
# regular operation it uses: .../fpm/php.ini
# And in the past it used: .../apache2/php.ini
2020-03-08 18:34:55 +00:00
2021-05-22 20:42:25 +00:00
- name : "Enact 'nginx_high_php_limits: True' in /etc/php/{{ php_version }}/fpm/php.ini for schools that use WordPress/Moodle/Nextcloud/PBX intensively (allow photos/docs up to 500MB, 300s timeouts, memory_limit = 512M for Nextcloud, max_input_vars = 5000 for Moodle)"
2020-02-16 07:47:45 +00:00
lineinfile :
2021-06-28 21:59:28 +00:00
path : /etc/php/{{ php_version }}/fpm/php.ini # COMPARE /etc/php/{{ php_version }}/cli/php.ini AND /etc/php/{{ php_version }}/apache2/php.ini
2020-02-16 07:47:45 +00:00
regexp : "{{ item.regexp }}"
line : "{{ item.line }}"
with_items :
- { regexp: '^upload_max_filesize', line : 'upload_max_filesize = 500M ; default is 2M' }
- { regexp: '^post_max_size', line : 'post_max_size = 500M ; default is 8M' }
- { regexp: '^max_execution_time', line : 'max_execution_time = 300 ; default is 30' }
- { regexp: '^max_input_time', line : 'max_input_time = 300 ; default is 60' }
2020-03-08 18:34:55 +00:00
- { regexp: '^memory_limit', line : 'memory_limit = 512M ; default is 128M / Nextcloud requests 512M' }
2021-06-28 21:59:28 +00:00
- { regexp: '^max_input_vars', line : 'max_input_vars = 5000 ; default is 1000 / Moodle 3.11+ requires 5000+ with PHP 8+' }
2021-06-28 17:29:58 +00:00
when: nginx_high_php_limits or moodle_install # REMINDER: THIS ENTIRE 5-STANZA BLOCK IS ONLY INVOKED... when : moodle_install or nextcloud_install or pbx_install or wordpress_install
2020-02-16 07:47:45 +00:00
2021-06-28 21:59:28 +00:00
- name : "Enact 'nginx_high_php_limits: True' in /etc/php/{{ php_version }}/cli/php.ini for schools that use WordPress/Moodle/Nextcloud/PBX intensively (allow photos/docs up to 500MB, 300s timeouts, memory_limit = 512M for Nextcloud, max_input_vars = 5000 for Moodle)"
2021-06-28 17:29:58 +00:00
lineinfile :
2021-06-28 21:59:28 +00:00
path : /etc/php/{{ php_version }}/cli/php.ini # COMPARE /etc/php/{{ php_version }}/fpm/php.ini AND /etc/php/{{ php_version }}/apache2/php.ini
2021-06-28 17:29:58 +00:00
regexp : "{{ item.regexp }}"
line : "{{ item.line }}"
with_items :
- { regexp: '^upload_max_filesize', line : 'upload_max_filesize = 500M ; default is 2M' }
- { regexp: '^post_max_size', line : 'post_max_size = 500M ; default is 8M' }
- { regexp: '^max_execution_time', line : 'max_execution_time = 300 ; default is 30' }
- { regexp: '^max_input_time', line : 'max_input_time = 300 ; default is 60' }
- { regexp: '^memory_limit', line : 'memory_limit = 512M ; default is 128M / Nextcloud requests 512M' }
2021-06-28 21:59:28 +00:00
- { regexp: '^max_input_vars', line : 'max_input_vars = 5000 ; default is 1000 / Moodle 3.11+ requires 5000+ with PHP 8+' }
when: nginx_high_php_limits or moodle_install # REMINDER: THIS ENTIRE 5-STANZA BLOCK IS ONLY INVOKED... when : moodle_install or nextcloud_install or pbx_install or wordpress_install
2021-06-28 17:29:58 +00:00
2021-06-28 21:59:28 +00:00
- name : Restart 'php{{ php_version }}-fpm' systemd service
2021-06-28 17:29:58 +00:00
systemd :
2021-06-28 21:59:28 +00:00
name : php{{ php_version }}-fpm
2021-06-28 17:29:58 +00:00
state : restarted
2021-06-28 21:59:28 +00:00
when : moodle_install or nextcloud_install or pbx_install or wordpress_install # 5-STANZA BLOCK ENDS. COMPARE apache_allow_sudo conditionals below.
2020-02-16 07:47:45 +00:00
2020-02-13 01:53:36 +00:00
# 'Is a "Rapid Power Off" button possible for low-electricity environments?'
# gives more details here: http://FAQ.IIAB.IO
2020-02-16 07:47:45 +00:00
# COMPARE nginx_high_php_limits further above.
2020-03-08 18:34:55 +00:00
# 2020-03-08: DOES THE FLAG BELOW (apache_allow_sudo) PRESUMABLY WORK
# WITH NGINX TOO ? (The single-click poweroff button on IIAB's home
# page certainly does still work with NGINX.)
2020-02-13 01:53:36 +00:00
- name : Give {{ apache_user }} (per variable apache_user) permission to poweroff, installing /etc/sudoers.d/020_apache_poweroff from template
template :
src : 020_apache_poweroff.j2
dest : /etc/sudoers.d/020_apache_poweroff
2020-10-11 00:39:50 +00:00
mode : '0440'
2020-10-16 20:46:19 +00:00
when : apache_allow_sudo
2020-02-13 01:53:36 +00:00
- name : Remove {{ apache_user }} (per variable apache_user) permission to poweroff, removing /etc/sudoers.d/020_apache_poweroff
file :
path : /etc/sudoers.d/020_apache_poweroff
state : absent
when : not apache_allow_sudo
2022-06-30 14:29:08 +00:00
# 2022-06-30: internet_available var removed
2022-06-29 22:37:13 +00:00
- name: 'Test for Internet access, using : {{ iiab_download_url }}/heart-beat.txt'
get_url :
url : "{{ iiab_download_url }}/heart-beat.txt"
dest : /tmp/heart-beat.txt
#timeout: "{{ download_timeout }}"
# @jvonau recommends: 100sec is too much (keep 10sec default)
ignore_errors : True
#async: 10
#poll: 2
register : internet_access_test
- name : Remove downloaded Internet test file /tmp/heart-beat.txt
file :
path : /tmp/heart-beat.txt
state : absent
2020-03-08 19:26:05 +00:00
- name : Run /usr/bin/iiab-refresh-wiki-docs (scraper script) to create http://box/info offline documentation. (This script was installed in Stage 3 = roles/3-base-server/tasks/main.yml, which ran roles/www_base/tasks/main.yml)
2020-02-13 01:53:36 +00:00
command : /usr/bin/iiab-refresh-wiki-docs
2022-06-29 22:37:13 +00:00
when : not internet_access_test.failed and not nodocs
2020-02-13 01:53:36 +00:00
2020-05-17 02:48:52 +00:00
- name : (Re)Start '{{ apache_service }}' systemd service, if installed & enabled
2020-02-14 03:53:19 +00:00
systemd :
name : "{{ apache_service }}" # apache2 on debuntu
state : restarted
2020-05-17 02:48:52 +00:00
when : apache_installed is defined and apache_enabled
2020-02-14 03:53:19 +00:00
- name : (Re)Start 'nginx' systemd service, if nginx_enabled
systemd :
name : nginx
state : restarted
2020-10-16 20:46:19 +00:00
when : nginx_enabled
2020-02-14 03:53:19 +00:00
2020-03-08 19:26:05 +00:00
# RECORD www_options AS INSTALLED
2020-02-13 01:53:36 +00:00
2020-03-08 19:26:05 +00:00
- name : "Set 'www_options_installed: True'"
2020-02-13 01:53:36 +00:00
set_fact :
2020-03-08 19:26:05 +00:00
www_options_installed : True
2020-02-13 01:53:36 +00:00
2020-03-08 19:26:05 +00:00
- name : "Add 'www_options_installed: True' to {{ iiab_state_file }}"
2020-02-13 01:53:36 +00:00
lineinfile :
path : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2020-03-08 19:26:05 +00:00
regexp : '^www_options_installed'
line: 'www_options_installed : True '