1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00

Merge pull request #303 from jvonau/avoid_1-prep

Avoid 1 prep - speeds up runtags
This commit is contained in:
A Holt 2017-10-26 12:32:40 -04:00 committed by GitHub
commit 40414f691b
20 changed files with 138 additions and 151 deletions

View file

@ -8,5 +8,6 @@
- vars/local_vars.yml
roles:
- { role: 0-init, tags: ['init'] }
- { role: 1-prep, tags: ['prep','platform','base'] }
- { role: openvpn, tags: ['openvpn'] }

View file

@ -9,7 +9,7 @@
- /etc/iiab/config_vars.yml
roles:
- { role: 1-prep, tags: ['prep','platform','base'] }
- { role: 0-init, tags: ['init'] }
- { role: 4-server-options, tags: ['options'] }
- { role: 5-xo-services, tags: ['xo-services'] }
- { role: 6-generic-apps, tags: ['generic-apps'] }

View file

@ -3,15 +3,17 @@
if [ -f /etc/iiab/iiab.env ]
then
. /etc/iiab/iiab.env
cd $XSCE_DIR
cd $IIAB_DIR
else
echo /etc/iiab/iiab.env is missing. Playbook has not been run.
exit 1
fi
CWD=`pwd`
if [ ! -f iiab-network.yml ]
then
echo "XSCE Playbook not found."
echo "IIAB Playbook not found."
echo "Please run this command from the top level of the git repo."
echo "Exiting."
exit
@ -22,7 +24,7 @@ then
touch /etc/iiab/config_vars.yml
fi
export ANSIBLE_LOG_PATH="$XSCE_DIR/iiab-network.log"
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

View file

@ -9,5 +9,5 @@
- /etc/iiab/config_vars.yml
roles:
- { role: 1-prep, tags: ['prep','platform','base'] }
- { role: 0-init, tags: ['network'] }
- { role: network, tags: ['network','base'] }

View file

@ -9,6 +9,7 @@
- /etc/iiab/config_vars.yml
roles:
- { role: 0-init, tags: ['init'] }
- { role: 1-prep, tags: ['prep','platform','base'] }
- { role: 2-common, tags: ['common','base'] }
- { role: 3-base-server, tags: ['base'] }

View file

@ -2,6 +2,7 @@
PLAYBOOK="iiab-base.yml"
INVENTORY="ansible_hosts"
CWD=`pwd`
if [ ! -f $PLAYBOOK ]
then
@ -14,5 +15,5 @@ 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="$XSCE_DIR/iiab-install.log"
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
ansible-playbook -i $INVENTORY $PLAYBOOK --connection=local

View file

@ -0,0 +1 @@
/opt/iiab/iiab/roles/1-prep/defaults/main.yml

View file

@ -0,0 +1,15 @@
- name: Determine if runansible was run
stat: path=/etc/iiab/iiab.env
register: NewInstall
- name: Setting first run flag
set_fact:
first_run: True
when: not NewInstall.stat.exists
# 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.
- include: roles/1-prep/tasks/iiab_ini.yml
when: first_run
# Now load the computed vars
- include: roles/1-prep/tasks/computed_vars.yml

View file

@ -6,49 +6,26 @@ gui_version: 2
# These are defaults for boolean routines,
first_run: False
installing: False
NUC6_firmware_needed: False
exFAT_enabled: False
no_NM_reload: False
has_WAN: False
wireless_lan_present: False
strict_networking: False
iiab_demo_mode: False
gw_active: False
gui_static_wan: False
discovered_wan_iface: "none"
gw_active: "none"
internet_available: False
is_F18: False
no_NM_reload: False
exFAT_enabled: False
gui_port: 80
# Set default for discovered hardware
rpi_model: none
is_rpi: False
xo_model: none
rtc_id: ds3231
NUC6_firmware_needed: False
# used in 2-common xo.yml
wifi_id: none
is_F20: False
is_F21: False
is_F22: False
is_F23: False
is_F24: False
# Set default for discovered hardware
driver_name: nl80211
rpi_model: none
is_rpi: False
xo_model: none
rtc_id: ds3231
# Set defaults for discovery process as strings
wifi1: "not found-1"
wifi2: "not found-2"
discovered_wan_iface: "none"
discovered_lan_iface: "none"
discovered_wireless_iface: "none"
iiab_wireless_lan_iface: "none"
iiab_lan_iface: "none"
iiab_wan_iface: "none"
device_gw: "none"
has_ifcfg_gw: "none"
has_wifi_gw: "none"
ap_device: "none"
device_gw2: ""
gui_port: 80
# must keep roles/iiab-admin/defaults/main.yml sync'd
admin_console_path: "{{ iiab_base }}/admin_console"
cmdsrv_path: "{{ iiab_base }}/iiab_cmdsrv"
iiab_cmdsrv_dbname : "iiab_cmdsrv.0.2.db"
wifi_id: none

View file

@ -14,6 +14,38 @@
exFAT_enabled: True
when: xo_model != "none"
# Discover do we have a gateway? -- if ansible detects gateway, becomes WAN candidate
- name: Finding gateway
set_fact:
discovered_wan_iface: "{{ ansible_default_ipv4.alias }}"
when: 'ansible_default_ipv4.gateway is defined'
- name: Verify gateway present
shell: ping -c4 "{{ ansible_default_ipv4.gateway }}" &> /dev/null ; echo $?
when: discovered_wan_iface != "none"
register: gw_active_test
- name: Recording gateway response
set_fact:
gw_active: True
when: discovered_wan_iface != "none" and gw_active_test.stdout == "0"
- name: Test for internet access
get_url: url="{{ iiab_download_url }}/heart-beat.txt" dest=/tmp/heart-beat.txt
ignore_errors: True
# async: 10
# poll: 2
register: internet_access_test
- name: Set internet_available true if wget succeeded
set_fact:
internet_available: True
when: not internet_access_test|failed and not disregard_network
- name: Cleanup internet test file
file: path=/tmp/heart-beat.txt
state=absent
- name: add version section
ini_file: dest='{{ iiab_config_file }}'
section=runtime
@ -36,6 +68,10 @@
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

View file

@ -1,21 +1,3 @@
- name: Determine if runansible was run
stat: path=/etc/iiab/iiab.env
register: NewInstall
- name: Setting first run flag
set_fact:
first_run: True
when: NewInstall.stat.exists is defined and not NewInstall.stat.exists
# we need to inialize the ini file
- include: iiab_ini.yml
when: first_run
- name: Set flag for fedora 18
set_fact:
is_F18: True
when: ansible_distribution_release == "based on Fedora 18" or ansible_distribution_version == "18"
- name: get the uuidgen program
package: name=uuid-runtime
state=present
@ -84,11 +66,7 @@
ignore_errors: true
- include: prep.yml
- include: computed_vars.yml
- include: detected_network.yml
when: not installing
when: first_run
# Put conditional actions for hardware platforms here
- include: raspberry_pi_2.yml

View file

@ -1,7 +1,7 @@
# This is a configuration file for XSCE
# It can sourced in a shell script or read into an application
XSCE_BASE_PATH={{ iiab_base }}
XSCE_DIR={{ iiab_dir }}
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 }}

View file

@ -1,5 +1,5 @@
- include: iiab_ini.yml
#- include: iiab_ini.yml
# create the directory structure for XSCE
- include: fl.yml

View file

@ -1,10 +1,36 @@
---
# Defaults for network detection
wireless_lan_present: False
strict_networking: False
iiab_demo_mode: False
gui_static_wan: False
# Set defaults for discovery process as strings
wifi1: "not found-1"
wifi2: "not found-2"
discovered_lan_iface: "none"
discovered_wireless_iface: "none"
#Redhat
iiab_lan_iface: "none"
iiab_wan_iface: "none"
iiab_wireless_lan_iface: "none"
device_gw: "none"
device_gw2: ""
has_WAN: False
has_ifcfg_gw: "none"
has_wifi_gw: "none"
ap_device: "none"
#Debian
dhcpcd_result: ""
wan_in_interfaces: False
# The values here are default local variables.
gui_wan_iface: "unset"
gui_static_wan_ip: "unset"
gui_desired_network_role: Gateway
wondershaper_dspeed: "4096"
wondershaper_upspeed: "1024"
# WiFi
host_ssid: IIAB
hostapd_wait: 10
@ -15,6 +41,7 @@ host_country_code: US
hostapd_secure: True
hostapd_password: "iiab2017"
driver_name: nl80211
network_config_dir: /etc/network/interfaces.d
iiab_network_mode: "Gateway"
dns_jail_enabled: False

View file

@ -155,7 +155,7 @@
- name: Add location section to config file
ini_file: dest='{{ iiab_config_file }}'
section=network
section=computed_network
option='{{ item.option }}'
value='{{ item.value }}'
with_items:

View file

@ -20,40 +20,6 @@
device_gw2: "{{ prior_gw.stdout }}"
when: not first_run and prior_gw is defined and prior_gw.stdout != ""
#pause checking
# Discover do we have a gateway? -- if ansible detects gateway, becomes WAN candidate
- name: Finding gateway
set_fact:
discovered_wan_iface: "{{ ansible_default_ipv4.alias }}"
when: 'ansible_default_ipv4.gateway is defined'
- name: Verify gateway present
shell: ping -c2 "{{ ansible_default_ipv4.gateway }}" &> /dev/null ; echo $?
register: gw_active_test
when: discovered_wan_iface != "none"
- name: Recording gateway response
set_fact:
gw_active: True
when: discovered_wan_iface != "none" and gw_active_test.stdout == "0"
- name: Test for internet access
get_url: url="{{ iiab_download_url }}/heart-beat.txt" dest=/tmp/heart-beat.txt
ignore_errors: True
# async: 10
# poll: 2
register: internet_access_test
- name: Set internet_available true if wget succeeded
set_fact:
internet_available: True
when: not internet_access_test|failed and not disregard_network
- name: Cleanup internet test file
file: path=/tmp/heart-beat.txt
state=absent
- name: Setting wan if detected
set_fact:
iiab_wan_iface: "{{ discovered_wan_iface }}"
@ -193,14 +159,10 @@
- name: Add location section to config file
ini_file: dest='{{ iiab_config_file }}'
section=network
section=detected_network
option='{{ item.option }}'
value='{{ item.value }}'
with_items:
- option: 'gw_active'
value: '{{ gw_active }}'
- option: 'internet_available'
value: '{{ internet_available }}'
- option: 'has_ifcfg_gw'
value: '{{ has_ifcfg_gw }}'
- option: 'discovered_wan_iface'

View file

@ -1,3 +1,9 @@
- include: detected_network.yml
when: not installing
tags:
- network
- network-discover
- include: computed_network.yml
when: not installing
tags:

View file

@ -1,4 +1,8 @@
#!/bin/bash -e
PLAYBOOK="iiab.yml"
INVENTORY="ansible_hosts"
# Pass cmdline options for ansible
ARGS="$@"
# copy var files to /etc/iiab for subsequent use
mkdir -p /etc/iiab
@ -28,13 +32,14 @@ fi
if [ -f /etc/iiab/iiab.env ]
then
. /etc/iiab/iiab.env
cd $XSCE_DIR
cd $IIAB_DIR
else
XSCE_DIR=/opt/iiab/iiab
IIAB_DIR=/opt/iiab/iiab
mkdir -p /etc/iiab
fi
CWD=`pwd`
if [ ! -f iiab.yml ]
if [ ! -f $PLAYBOOK ]
then
echo "IIAB Playbook not found."
echo "Please run this command from the top level of the git repo."
@ -47,34 +52,10 @@ if [ ! -f /etc/ansible/facts.d/local_facts.fact ]; then
fi
cp ./scripts/local_facts.fact /etc/ansible/facts.d/local_facts.fact
PLAYBOOK="iiab.yml"
INVENTORY="ansible_hosts"
CWD=`pwd`
echo "Running local playbooks! "
XSDOMAIN=""
# Pass in Existing Domain
if [ -f /etc/sysconfig/xs_domain_name ]
then
XSDOMAIN=`cat /etc/sysconfig/xs_domain_name`
fi
# Or accept Domain on command line
if [ x"$1" != x ]
then
XSDOMAIN=$1
fi
# Pass in git location
if [ x"$XSDOMAIN" != x ]
then
ARGS="--extra-vars '{\"iiab_domain\":\"$XSDOMAIN\"}'"
else
ARGS=""
fi
export ANSIBLE_LOG_PATH="$XSCE_DIR/iiab-install.log"
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local

23
runtags
View file

@ -1,20 +1,19 @@
#!/bin/bash
# copy var files to /etc/iiab for subsequent use
#./install-init
# if not the first run, repo location is here
PLAYBOOK="iiab.yml"
INVENTORY="ansible_hosts"
# Pass cmdline options for ansible
if [ -f /etc/iiab/iiab.env ]
then
. /etc/iiab/iiab.env
cd $XSCE_DIR
cd $IIAB_DIR
fi
if [ ! -f iiab.yml ]
CWD=`pwd`
if [ ! -f $PLAYBOOK ]
then
echo "XSCE Playbook not found."
echo "IIAB Playbook not found."
echo "Please run this command from the top level of the git repo."
echo "Exiting."
exit
@ -36,7 +35,7 @@ found="N"
for tag in $tags
do
if [ "$tag" == "prep" ]
if [ "$tag" == "init" ]
then
found="Y"
fi
@ -48,8 +47,8 @@ taglist=$1
if [ "$found" == "N" ]
then
taglist="prep,"$taglist
taglist="init,"$taglist
fi
export ANSIBLE_LOG_PATH="$XSCE_DIR/iiab-debug.log"
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
ansible-playbook -i ansible_hosts iiab.yml --connection=local --tags="""$taglist"""