1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Merge pull request #24 from jvonau/iiab-install

sync from jvonau/iiab branch iiab-install
This commit is contained in:
A Holt 2017-10-30 16:24:21 -04:00 committed by GitHub
commit 20cb253da0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 214 additions and 99 deletions

74
iiab-install Executable file
View file

@ -0,0 +1,74 @@
#!/bin/bash -e
# running from a git repo
PLAYBOOK="iiab-steps.yml"
INVENTORY="ansible_hosts"
CWD=`pwd`
# Add cmdline options for passing to ansible
# todo add proper shift to gobble up --debug --reinstall
ARGS=""
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
if [ ! -f /etc/ansible/facts.d/local_facts.fact ]; then
mkdir -p /etc/ansible/facts.d
fi
cp ./scripts/local_facts.fact /etc/ansible/facts.d/local_facts.fact
STAGE=""
if [ ! -f /etc/iiab/iiab.env ]; then
mkdir -p /etc/iiab
else
OLD=`grep XSCE /etc/iiab/iiab.env | wc -l`
if [ "$OLD" != 0 ] || [ "$1" = "--reinstall" ]; then
echo "Found old XSCE install - re-installing from scratch"
rm /etc/iiab/iiab.env
# check ansible version here and force ansible upgrade if needed
else
source /etc/iiab/iiab.env
if [ $STAGE == 9 ] && [ "$1" = "--debug" ]; then
echo "Entering debug mode"
sed -i -e 's/^STAGE=.*/STAGE=2/' /etc/iiab/iiab.env
elif [ ! $STAGE == 9 ]; then
echo "Restarting from STAGE $STAGE"
else
# place keeper add read response
# "offer 'Y' or stage number dialog box option to override"
echo "'iiab-install' has already been completed"
echo "use --debug to override "
#echo "In demo mode not preventing second run"
echo "Exiting."
exit 1
fi
fi
fi
if [ ! -f $PLAYBOOK ]; then
echo "IIAB Playbook not found."
echo "Please run this command from the top level of the git repo."
echo "Exiting."
exit 1
fi
# if vars/local_vars.yml is missing, put a default one in place - First Run
if [ ! -f ./vars/local_vars.yml ]; then
OS=`grep ^ID= /etc/*release|cut -d= -f2`
OS=${OS//\"/}
case $OS in
OLPC | fedora)
cp ./vars/olpc.localvars ./vars/local_vars.yml
;;
centos | debian | ubuntu | raspbian)
cp ./vars/medium.localvars ./vars/local_vars.yml
;;
*)
echo "IIAB supports raspbian, debian, ubuntu, centos, and OLPC - exiting now..."
exit 1
;;
esac
fi
echo "Running local playbooks! "
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local

View file

@ -1,15 +1,8 @@
#!/bin/bash
if [ -f /etc/iiab/iiab.env ]
then
. /etc/iiab/iiab.env
cd $IIAB_DIR
else
echo /etc/iiab/iiab.env is missing. Playbook has not been run.
exit 1
fi
# running from a git repo
# ansible files exist
CWD=`pwd`
export ANSIBLE_LOG_PATH="$CWD/iiab-network.log"
if [ ! -f iiab-network.yml ]
then
@ -24,7 +17,6 @@ then
touch /etc/iiab/config_vars.yml
fi
export ANSIBLE_LOG_PATH="$CWD/iiab-network.log"
ansible-playbook -i ansible_hosts iiab-network.yml --connection=local
echo "" >> iiab-network.log
ls -la /etc/sys*/net*/ifcfg* >> iiab-network.log

29
iiab-steps.yml Normal file
View file

@ -0,0 +1,29 @@
---
- hosts: all
become: yes
vars_files:
- vars/default_vars.yml
- vars/{{ ansible_local.local_facts.os_ver }}.yml
- vars/local_vars.yml
roles:
- { role: 0-init, tags: ['0-init'] }
- { role: 1-prep, tags: ['1-prep','platform','base'],
when: ansible_local.local_facts.stage|int < 1 }
- { role: 2-common, tags: ['2-common','base'],
when: ansible_local.local_facts.stage|int < 2 }
- { role: 3-base-server, tags: ['3-base-server','base'],
when: ansible_local.local_facts.stage|int < 3 }
- { role: 4-server-options, tags: ['4-server-options'],
when: ansible_local.local_facts.stage|int < 4 }
- { role: 5-xo-services, tags: ['5-xo-services'],
when: ansible_local.local_facts.stage|int < 5 }
- { role: 6-generic-apps, tags: ['6-generic-apps'],
when: ansible_local.local_facts.stage|int < 6 }
- { role: 7-edu-apps, tags: ['7-edu-apps'],
when: ansible_local.local_facts.stage|int < 7 }
- { role: 8-mgmt-tools, tags: ['8-mgmt-tools'],
when: ansible_local.local_facts.stage|int < 8 }
- { role: 9-local-addons, tags: ['9-local-addons'],
when: ansible_local.local_facts.stage|int < 9 }

View file

@ -4,6 +4,8 @@ PLAYBOOK="iiab-base.yml"
INVENTORY="ansible_hosts"
CWD=`pwd`
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
if [ ! -f $PLAYBOOK ]
then
echo "IIAB Playbook not found."
@ -15,5 +17,4 @@ fi
sed -i -e "s/openvpn_install: False/openvpn_install: True/" vars/local_vars.yml
sed -i -e "s/openvpn_enabled: False/openvpn_enabled: True/" vars/local_vars.yml
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local

View file

@ -6,8 +6,9 @@
# set top level variables from local facts for convenience
- set_fact:
xo_model: '{{ ansible_local["local_facts"]["xo_model"] }}'
phplib_dir: '{{ ansible_local["local_facts"]["phplib_dir"] }}'
xo_model: '{{ ansible_local.local_facts.xo_model }}'
phplib_dir: '{{ ansible_local.local_facts.phplib_dir }}'
iiab_stage: '{{ ansible_local.local_facts.stage }}'
- name: Set exFAT enabled for XO laptops
set_fact:
@ -46,33 +47,6 @@
file: path=/tmp/heart-beat.txt
state=absent
- name: add version section
ini_file: dest='{{ iiab_config_file }}'
section=runtime
option='{{ item.option }}'
value='{{ item.value }}'
with_items:
- 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: 'runtime_php'
value: '{{ phplib_dir }}'
- 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 }}'
# 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
set_fact: local_tz='UTC'
@ -176,3 +150,34 @@
set_fact:
is_CentOS: True
when: ansible_distribution == "CentOS"
- name: add version section
ini_file: dest='{{ iiab_config_file }}'
section=runtime
option='{{ item.option }}'
value='{{ item.value }}'
with_items:
- option: 'iiab_stage'
value: '{{ iiab_stage }}'
- 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 }}'

View file

@ -1,6 +1,6 @@
# Preparations (Hardware Level)
- name: ...IS BEGINNING ============================================
- name: ...IS BEGINNING ==================================
command: echo
- name: Get the uuidgen program
@ -88,5 +88,10 @@
url={{ iiab_download_url }}/iwlwifi-8000C-13.ucode
when: first_run and usb_NUC6.stdout|int > 0
- name: ...HAS COMPLETED ===========================================
command: echo
# this script can be sourced to get IIAB location
- name: Recording STAGE 1 HAS COMPLETED ==================
template: src=roles/1-prep/templates/iiab.env.j2
dest=/etc/iiab/iiab.env
owner=root
group=root
mode=0644

View file

@ -1,7 +1,8 @@
# This is a configuration file for XSCE
# This is a configuration file for IIAB
# It can sourced in a shell script or read into an application
IIAB_BASE_PATH={{ iiab_base }}
IIAB_DIR={{ iiab_dir }}
OS={{ ansible_local.local_facts.os }}
OS_VER={{ ansible_local.local_facts.os_ver }}
WWWROOT={{ doc_root }}
STAGE=1

View file

@ -1,6 +1,6 @@
# Common OS-Level Additions & Mods (that only need to be performed once)
- name: ...IS BEGINNING ==========================================
- name: ...IS BEGINNING ==================================
command: echo
#- include: iiab_ini.yml
@ -48,5 +48,8 @@
- include: udev.yml
- name: ...HAS COMPLETED =========================================
command: echo
- name: Recording STAGE 2 HAS COMPLETED ==================
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=2'
state=present

View file

@ -1,6 +1,5 @@
# Base Server
- name: ...IS BEGINNING =====================================
- name: ...IS BEGINNING ==================================
command: echo
- name: HTTPD
@ -30,12 +29,9 @@
state=restarted
when: not installing
# If we got here we're done
#- name: Record base gui version
# lineinfile: dest=/etc/iiab/iiab.env
# regexp='^BASE_VERSION=*'
# line='BASE_VERSION="{{ gui_version }}"'
# state=present
- name: Record STAGE 3 HAS COMPLETED =====================
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=3'
state=present
- name: ...HAS COMPLETED ====================================
command: echo

View file

@ -1,5 +1,4 @@
# Server Options
- name: ...IS BEGINNING ==================================
command: echo
@ -57,14 +56,6 @@
when: usb_lib_install
tags: usb-lib
# this script can be sourced to get IIAB location
- name: Create iiab.env file
template: src=roles/1-prep/templates/iiab.env.j2
dest=/etc/iiab/iiab.env
owner=root
group=root
mode=0644
- name: Put a Python interface to iiab.env
template: src=roles/1-prep/templates/iiab_env.py.j2
dest=/etc/iiab/iiab_env.py
@ -73,5 +64,8 @@
command: /usr/bin/iiab-refresh-wiki-docs
when: not nodocs
- name: ...HAS COMPLETED =================================
command: echo
- name: Recording STAGE 4 HAS COMPLETED ==================
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=4'
state=present

View file

@ -1,6 +1,5 @@
# XO Services
- name: ...IS BEGINNING =====================================
- name: ...IS BEGINNING ==================================
command: echo
- name: ACTIVITY-SERVER
@ -21,5 +20,8 @@
when: idmgr_install
tags: olpc, idmgr
- name: ...HAS COMPLETED ====================================
command: echo
- name: Recording STAGE 5 HAS COMPLETED ==================
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=5'
state=present

View file

@ -1,6 +1,5 @@
# Generic Apps
- name: ...IS BEGINNING ====================================
- name: ...IS BEGINNING ==================================
command: echo
- name: CALIBRE
@ -45,5 +44,8 @@
when: wordpress_install
tags: wordpress
- name: ...HAS COMPLETED ===================================
command: echo
- name: Recording STAGE 6 HAS COMPLETED ==================
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=6'
state=present

View file

@ -1,6 +1,5 @@
# Educational Apps
- name: ...IS BEGINNING ========================================
- name: ...IS BEGINNING ==================================
command: echo
- name: KALITE
@ -39,5 +38,8 @@
when: sugarizer_install
tags: sugarizer
- name: ...HAS COMPLETED =======================================
command: echo
- name: Recording STAGE 7 HAS COMPLETED ==================
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=7'
state=present

View file

@ -1,6 +1,6 @@
# Assessment and Monitoring Tools
- name: ...IS BEGINNING ======================================
- name: ...IS BEGINNING ==================================
command: echo
- name: AWSTATS
@ -51,5 +51,8 @@
when: xovis_install and ansible_distribution != "CentOS"
tags: xovis
- name: ...HAS COMPLETED =====================================
command: echo
- name: Recording STAGE 8 HAS COMPLETED ==================
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=8'
state=present

View file

@ -1,7 +1,10 @@
# Local Add-ons
- name: ...IS BEGINNING ====================================
- name: ...IS BEGINNING =============================
command: echo
- name: ...HAS COMPLETED ===================================
command: echo
- name: Recording STAGE 9 HAS COMPLETED =============
lineinfile: dest=/etc/iiab/iiab.env
regexp='^STAGE=*'
line='STAGE=9'
state=present

14
runtags
View file

@ -1,16 +1,11 @@
#!/bin/bash
# running from a git repo
PLAYBOOK="iiab.yml"
INVENTORY="ansible_hosts"
# Pass cmdline options for ansible
if [ -f /etc/iiab/iiab.env ]
then
. /etc/iiab/iiab.env
cd $IIAB_DIR
fi
CWD=`pwd`
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
if [ ! -f $PLAYBOOK ]
then
echo "IIAB Playbook not found."
@ -41,8 +36,6 @@ do
fi
done
# echo $found
taglist=$1
if [ "$found" == "N" ]
@ -50,5 +43,4 @@ then
taglist="0-init,"$taglist
fi
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
ansible-playbook -i ansible_hosts iiab.yml --connection=local --tags="""$taglist"""

View file

@ -41,13 +41,24 @@ else
XO_VERSION="none"
fi
# upgrades return found, clean installs return 0
# interruptions return last stage number recorded (1-9)
if [ -f /etc/iiab/iiab.env ]
then
STAGE=1
source /etc/iiab/iiab.env
STAGE=$STAGE
else
STAGE=0
fi
ANSIBLE_VERSION=$(ansible --version|head -n 1|cut -f 2 -d " ")
cat <<EOF
{"phplib_dir" : "$PHPLIB_DIR",
"stage" : "$STAGE",
"iiab_branch" : "$BRANCH",
"iiab_commit" : "$COMMIT",
"xo_model" : "$XO_VERSION",
"ansble_version" : "$ANSIBLE_VERSION",
"ansible_version" : "$ANSIBLE_VERSION",
"os" : "$OS",
"os_ver" : "$OS_VER"}