1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/0-init/tasks/main.yml

226 lines
6.5 KiB
YAML
Raw Normal View History

2017-10-27 05:44:50 +00:00
# Initialize
- name: ...IS BEGINNING ============================================
2017-12-08 07:02:28 +00:00
stat:
path: /etc/iiab/iiab.env
2017-09-22 10:02:42 +00:00
register: NewInstall
- name: Setting first run flag
set_fact:
first_run: True
when: not NewInstall.stat.exists
2018-07-23 12:05:13 +00:00
# We need to inialize the ini file and only write the location and version
# sections once and only once to preserve the install date and git hash.
2017-11-03 03:36:11 +00:00
- name: Write iiab_ini.yml for the first time
2017-11-09 10:51:07 +00:00
include_tasks: first_run.yml
2017-09-22 10:02:42 +00:00
when: first_run
2017-10-27 05:44:50 +00:00
#- name: Loading computed_vars
# include_tasks: roles/0-init/tasks/computed_vars.yml
2017-11-10 03:06:57 +00:00
- name: Re-read local_facts.facts from /etc/ansible/facts.d
2017-12-08 07:02:28 +00:00
setup:
filter: ansible_local
2018-07-27 20:03:34 +00:00
- name: Set top-level variables from local_facts for convenience
2017-11-16 11:56:03 +00:00
set_fact:
2017-12-08 07:02:28 +00:00
xo_model: "{{ ansible_local.local_facts.xo_model }}"
phplib_dir: "{{ ansible_local.local_facts.phplib_dir }}"
iiab_stage: "{{ ansible_local.local_facts.stage }}"
2018-07-27 20:03:34 +00:00
- name: Discover if this is running Raspbian -- if so assume it is an RPi
set_fact:
2017-12-08 07:02:28 +00:00
rpi_model: "rpi"
is_rpi: True
# no_net_restart: True
# nobridge: True
when: ansible_local.local_facts.os == "raspbian"
- name: Set exFAT enabled for XO laptops
set_fact:
2017-12-08 07:02:28 +00:00
exFAT_enabled: True
when: xo_model != "none"
2018-07-23 12:05:13 +00:00
# Discover: do we have a gateway?
# If Ansible detects gateway, becomes WAN candidate.
- name: Finding gateway
set_fact:
2017-12-08 07:02:28 +00:00
discovered_wan_iface: "{{ ansible_default_ipv4.alias }}"
iiab_wan_iface: "{{ discovered_wan_iface }}"
when: ansible_default_ipv4.gateway is defined
- name: Verify gateway present
shell: ping -c4 "{{ ansible_default_ipv4.gateway }}" | grep icmp_seq=4 | wc -l
when: discovered_wan_iface != "none"
register: gw_active_test
- name: Recording gateway response
set_fact:
2017-12-08 07:02:28 +00:00
gw_active: True
when: discovered_wan_iface != "none" and gw_active_test.stdout == "1"
2018-07-27 20:03:34 +00:00
- name: Test for Internet access
2017-12-08 07:02:28 +00:00
get_url:
url: "{{ iiab_download_url }}/heart-beat.txt"
dest: /tmp/heart-beat.txt
2017-12-18 16:12:58 +00:00
# timeout: "{{ download_timeout }}"
# @jvonau recommends: 100sec is too much (keep 10sec default)
ignore_errors: True
# async: 10
# poll: 2
register: internet_access_test
- name: Set internet_available true if wget succeeded
set_fact:
2017-12-08 07:02:28 +00:00
internet_available: True
when: not internet_access_test.failed and not disregard_network
2018-07-27 20:08:20 +00:00
- name: Remove Internet test file
2017-12-08 07:02:28 +00:00
file:
path: /tmp/heart-beat.txt
state: absent
2018-07-23 12:05:13 +00:00
# Put all computed vars here so derive properly from any prior var file.
- name: If the TZ is not set in env, set it to UTC
include_tasks: tz.yml
- name: Set port 80 for Admin Console
set_fact:
gui_port: 80
when: not adm_cons_force_ssl
- name: Set port 443 for Admin Console
set_fact:
gui_port: 443
when: adm_cons_force_ssl
- name: Require MySQL to be on (mandatory in Stage 3!)
set_fact:
mysql_install: True
mysql_enabled: True
2018-07-23 12:05:13 +00:00
# We decided to enable mysql unconditionally.
# when: elgg_enabled or rachel_enabled or owncloud_enabled or phpmyadmin_enabled or wordpress_enabled or iiab_menu_install
2018-07-23 12:05:13 +00:00
# Late 2017: Had commented out MongoDB on a trial basis, for a more basic/lightweight Sugarizer, per https://github.com/iiab/iiab/pull/427
2018-07-27 20:03:34 +00:00
- name: Turn on vars for MongoDB if Sugarizer enabled
set_fact:
mongodb_install: True
mongodb_enabled: True
when: sugarizer_enabled
# There might be other db's
2018-07-27 20:03:34 +00:00
- name: Turn on vars for PostgreSQL if Moodle or Pathagar enabled
set_fact:
postgresql_install: True
postgresql_enabled: True
when: moodle_enabled or (pathagar is defined and pathagar_enabled)
2018-08-30 21:29:47 +00:00
#- name: Turn on vars for Docker if SchoolTool is to be installed
# set_fact:
# docker_install: True
# docker_enabled: True
# when: schooltool_enabled or schooltool_install
2017-11-10 03:06:57 +00:00
- name: Set python_path (redhat)
set_fact:
2018-03-30 17:34:42 +00:00
python_path: /lib/python2.7/site-packages/
when: is_redhat
2017-11-10 03:06:57 +00:00
- name: Set python_path (debuntu)
set_fact:
python_path: /usr/local/lib/python2.7/dist-packages/
when: is_debuntu
2018-07-23 12:05:13 +00:00
# For various reasons the mysql service cannot be enabled on Fedora 20, but
# 'mariadb', which is its real name can. On Fedora 18 we need to use 'mysqld'.
2018-07-22 22:49:32 +00:00
- name: Set mysql_service to mariadb by default
set_fact:
mysql_service: mariadb
2018-07-22 22:49:32 +00:00
- name: Set mysql_service to mysqld etc (Fedora 18)
set_fact:
mysql_service: mysqld
no_NM_reload: True
is_F18: True
2018-04-29 03:50:59 +00:00
when: (ansible_distribution_release == "based on Fedora 18" or ansible_distribution_version == "18") and ansible_distribution == "Fedora"
2017-11-10 03:06:57 +00:00
- name: Set mysql_service to mysql (debuntu)
set_fact:
mysql_service: mysql
when: is_debuntu
2017-11-14 04:16:24 +00:00
- name: Set FQDN
2017-11-06 22:45:06 +00:00
set_fact:
2017-12-08 07:02:28 +00:00
iiab_fqdn: "{{ iiab_hostname }}.{{ iiab_domain }}"
FQDN_changed: False
2017-11-06 22:45:06 +00:00
- name: FQDN changed
set_fact:
2017-12-08 07:02:28 +00:00
FQDN_changed: True
2017-11-06 22:45:06 +00:00
when: iiab_fqdn != ansible_fqdn
2018-07-27 20:03:34 +00:00
- name: Set hostname if FQDN_changed
2018-05-17 16:42:33 +00:00
include_tasks: hostname.yml
when: FQDN_changed
2018-07-23 12:05:13 +00:00
- name: Add 'runtime' section alongside list of services at /etc/iiab/iiab.ini
2017-12-08 07:02:28 +00:00
ini_file:
dest: "{{ iiab_config_file }}"
section: runtime
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- option: iiab_stage
value: "{{ iiab_stage }}"
- option: iiab_base_ver
value: "{{ iiab_base_ver }}"
- option: iiab_revision
value: "{{ iiab_revision }}"
- option: runtime_php
value: "{{ phplib_dir }}"
- option: runtime_branch
value: "{{ ansible_local.local_facts.iiab_branch }}"
- option: runtime_commit
value: "{{ ansible_local.local_facts.iiab_commit }}"
- option: runtime_date
value: "{{ ansible_date_time.iso8601 }}"
- option: ansible_version
value: "{{ ansible_local.local_facts.ansible_version }}"
- option: kernel
value: "{{ ansible_kernel }}"
- option: memory_mb
value: "{{ ansible_memtotal_mb }}"
- option: swap_mb
value: "{{ ansible_swaptotal_mb }}"
- option: product_id
value: "{{ ansible_product_uuid }}"
- option: gw_active
value: "{{ gw_active }}"
- option: internet_available
value: "{{ internet_available }}"
- option: is_rpi
value: "{{ is_rpi }}"
- option: first_run
value: "{{ first_run }}"
- option: local_tz
value: "{{ local_tz }}"
- option: FQDN_changed
value: "{{ FQDN_changed }}"
2018-07-27 20:03:34 +00:00
#- name: Now changing FQDN
# include_tasks: hostname.yml
# when: FQDN_changed
2017-11-06 22:45:06 +00:00
- name: STAGE 0 HAS COMPLETED ======================================
2017-12-08 07:02:28 +00:00
ini_file:
dest: "{{ iiab_config_file }}"
section: runtime
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- option: is_VM
value: "yes"
when: is_VM is defined