diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..c62e3adb4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,5 @@ +### Expected behavior and actual behavior. + +### Steps to reproduce the problem. + +### Specifications like the version of the IIAB, operating system version, or hardware details. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..61851e1dd --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +### Fixes Bug + +### Description of changes proposed in this pull request. + +### Smoke-tested in operating system. + +### Mention a team member for further information or comment using @ name diff --git a/iiab-base.yml b/iiab-base.yml index 4c42c01e7..a359808d9 100644 --- a/iiab-base.yml +++ b/iiab-base.yml @@ -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'] } diff --git a/iiab-from-console.yml b/iiab-from-console.yml index fb47ca868..1c29d7b18 100644 --- a/iiab-from-console.yml +++ b/iiab-from-console.yml @@ -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'] } diff --git a/iiab-network b/iiab-network index 5a065e556..9e24154be 100755 --- a/iiab-network +++ b/iiab-network @@ -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 diff --git a/iiab-network.yml b/iiab-network.yml index 40cd8f589..989108cb3 100644 --- a/iiab-network.yml +++ b/iiab-network.yml @@ -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'] } diff --git a/iiab.yml b/iiab.yml index f4cafc001..b46cac86e 100644 --- a/iiab.yml +++ b/iiab.yml @@ -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'] } diff --git a/install-support b/install-support index cd73aade8..b7df01489 100755 --- a/install-support +++ b/install-support @@ -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 diff --git a/roles/0-init/defaults/main.yml b/roles/0-init/defaults/main.yml new file mode 120000 index 000000000..b8fa87d4b --- /dev/null +++ b/roles/0-init/defaults/main.yml @@ -0,0 +1 @@ +/opt/iiab/iiab/roles/1-prep/defaults/main.yml \ No newline at end of file diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml new file mode 100644 index 000000000..54ec4b7d3 --- /dev/null +++ b/roles/0-init/tasks/main.yml @@ -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 diff --git a/roles/1-prep/defaults/main.yml b/roles/1-prep/defaults/main.yml index 71af080a7..89df65e47 100644 --- a/roles/1-prep/defaults/main.yml +++ b/roles/1-prep/defaults/main.yml @@ -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 diff --git a/roles/1-prep/tasks/computed_vars.yml b/roles/1-prep/tasks/computed_vars.yml index e775e9fc3..964f0b723 100644 --- a/roles/1-prep/tasks/computed_vars.yml +++ b/roles/1-prep/tasks/computed_vars.yml @@ -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 diff --git a/roles/1-prep/tasks/main.yml b/roles/1-prep/tasks/main.yml index dc9672c67..60b896567 100644 --- a/roles/1-prep/tasks/main.yml +++ b/roles/1-prep/tasks/main.yml @@ -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 diff --git a/roles/1-prep/templates/iiab.env.j2 b/roles/1-prep/templates/iiab.env.j2 index 602256841..b472d4fe6 100644 --- a/roles/1-prep/templates/iiab.env.j2 +++ b/roles/1-prep/templates/iiab.env.j2 @@ -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 }} diff --git a/roles/2-common/tasks/main.yml b/roles/2-common/tasks/main.yml index 33a5388da..fe42574dc 100644 --- a/roles/2-common/tasks/main.yml +++ b/roles/2-common/tasks/main.yml @@ -1,5 +1,5 @@ -- include: iiab_ini.yml +#- include: iiab_ini.yml # create the directory structure for XSCE - include: fl.yml diff --git a/roles/kiwix/tasks/main.yml b/roles/kiwix/tasks/main.yml index 92ea14d6d..7b8c5f262 100644 --- a/roles/kiwix/tasks/main.yml +++ b/roles/kiwix/tasks/main.yml @@ -6,13 +6,13 @@ - name: Set kiwix source file name x86_64 set_fact: - kiwix_src_file: "kiwix-tools_linux64_2017-10-11.tar.gz" + kiwix_src_file: "kiwix-tools_linux64_2017-10-25.tar.gz" kiwix_src_bin_only: True when: ansible_machine == "x86_64" - name: Set kiwix source file name armv7l set_fact: - kiwix_src_file: "kiwix-tools_armhf_2017-10-11.tar.gz" + kiwix_src_file: "kiwix-tools_armhf_2017-10-25.tar.gz" kiwix_src_bin_only: True when: ansible_machine == "armv7l" or ansible_machine == "armv6l" diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index 722761dda..25c7b6b31 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -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 diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index 28cb52463..4b4b0f1ef 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -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: diff --git a/roles/1-prep/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml similarity index 84% rename from roles/1-prep/tasks/detected_network.yml rename to roles/network/tasks/detected_network.yml index 502f3dc1c..e38409257 100644 --- a/roles/1-prep/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -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' diff --git a/roles/1-prep/tasks/detected_redhat.yml b/roles/network/tasks/detected_redhat.yml similarity index 100% rename from roles/1-prep/tasks/detected_redhat.yml rename to roles/network/tasks/detected_redhat.yml diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index 5e93f5c3f..20a94af78 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -1,3 +1,9 @@ +- include: detected_network.yml + when: not installing + tags: + - network + - network-discover + - include: computed_network.yml when: not installing tags: diff --git a/runansible b/runansible index 2a6ea4954..51cee7876 100755 --- a/runansible +++ b/runansible @@ -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 diff --git a/runtags b/runtags index 933d07a67..ae25ea4df 100755 --- a/runtags +++ b/runtags @@ -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"""