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
2023-06-10 13:10:47 +00:00
- name : Record (initial) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df1
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
2023-07-15 03:18:31 +00:00
path : "{{ doc_root }}{{ iiab_home_url }}" # e.g. /library/www/html/home
2020-02-13 01:53:36 +00:00
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
2023-04-10 02:38:21 +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
# 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
2022-07-23 00:31:19 +00:00
2022-07-23 00:42:29 +00:00
# 2022-07-22: SIMILAR TO roles/iiab-admin/tasks/pwd-warnings.yml FOR passwords
# AND roles/network/tasks/netwarn.yml FOR iiab-network
2020-02-13 01:53:36 +00:00
2022-07-22 22:37:00 +00:00
- name : Does /etc/xdg/lxsession/LXDE-pi/autostart exist? (if so, auto-launch browser on boot, displaying http://box/home IIAB home page)
2020-10-31 23:05:37 +00:00
stat :
2022-05-23 23:51:01 +00:00
path : /etc/xdg/lxsession/LXDE-pi/autostart
2022-07-21 18:45:37 +00:00
register : lxde_pi_autostart_present
2020-10-31 23:05:37 +00:00
2022-07-21 18:45:37 +00:00
- name : Does /usr/bin/chromium exist? (check for browser filename change)
2020-11-03 04:14:18 +00:00
stat :
2022-05-23 23:51:01 +00:00
path : /usr/bin/chromium
2020-11-03 04:14:18 +00:00
register : chromium_present
2022-07-21 18:45:37 +00:00
- name : Add chromium-browser to /etc/xdg/lxsession/LXDE-pi/autostart
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'
2022-07-21 18:45:37 +00:00
line : '/usr/bin/chromium-browser --disable-restore-session-state http://box/home'
when : lxde_pi_autostart_present.stat.exists and not chromium_present.stat.exists
2020-11-03 04:14:18 +00:00
2022-07-21 18:45:37 +00:00
- name : Add chromium to /etc/xdg/lxsession/LXDE-pi/autostart
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'
2022-07-21 18:45:37 +00:00
line : '/usr/bin/chromium --disable-restore-session-state http://box/home'
when : lxde_pi_autostart_present.stat.exists and chromium_present.stat.exists
2020-10-31 23:05:37 +00:00
2021-06-28 21:59:28 +00:00
2022-12-30 09:09:46 +00:00
# 2022-12-29: php-settings.yml is ALSO attempted (on demand) by every
2022-12-29 19:45:09 +00:00
# <ROLE>/tasks/install.yml that needs it (Matomo, Moodle, Nextcloud, PBX,
# WordPress) so './runrole <ROLE>' and similar are fully self-sufficient!
2022-12-30 09:09:46 +00:00
- name : "Run php-settings.yml -- allows post-install toggling of nginx_high_php_limits in /etc/iiab/local_vars.yml -- if you run './runrole www_options'"
include_tasks : php-settings.yml
2023-08-24 14:45:33 +00:00
when : nginx_high_php_limits or matomo_install or moodle_install or nextcloud_install or pbx_install or wordpress_install
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
2023-06-10 13:10:47 +00:00
- name : Record (final) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df2
2023-06-10 13:10:47 +00:00
- name : Add 'www_options_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
2023-05-27 07:26:04 +00:00
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : www_options
option : www_options_disk_usage
2023-06-10 13:10:47 +00:00
value : "{{ df2.stdout|int - df1.stdout|int }}"
2023-05-27 07:26:04 +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 '