From 4e57383379865e2942463b000a0f18b180069159 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 4 Mar 2020 17:02:01 -0600 Subject: [PATCH] replace is_rpi with rpi_model --- roles/0-init/defaults/main.yml | 1 - roles/0-init/tasks/main.yml | 13 +++---------- roles/1-prep/tasks/raspberry_pi.yml | 2 +- scripts/local_facts.fact | 7 +++++++ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/roles/0-init/defaults/main.yml b/roles/0-init/defaults/main.yml index 517936aa0..14f589397 100644 --- a/roles/0-init/defaults/main.yml +++ b/roles/0-init/defaults/main.yml @@ -7,7 +7,6 @@ # These are defaults for boolean routines. first_run: False rpi_model: none -is_rpi: False xo_model: none gw_active: False internet_available: False diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index b017a837a..4b933f5fd 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -57,18 +57,11 @@ - name: Set top-level variables from local_facts for convenience set_fact: + rpi_model: "{{ ansible_local.local_facts.rpi_model }}" xo_model: "{{ ansible_local.local_facts.xo_model }}" phplib_dir: "{{ ansible_local.local_facts.phplib_dir }}" iiab_stage: "{{ ansible_local.local_facts.stage }}" -- name: Discover if this is running Raspbian -- if so assume it is an RPi - set_fact: - rpi_model: "rpi" - is_rpi: True - #no_net_restart: True - #nobridge: True - when: ansible_local.local_facts.os == "raspbian" - - name: Set exFAT_enabled if xo_model != "none" set_fact: exFAT_enabled: True @@ -216,8 +209,8 @@ value: "{{ gw_active }}" - option: internet_available value: "{{ internet_available }}" - - option: is_rpi - value: "{{ is_rpi }}" + - option: rpi_model + value: "{{ rpi_model }}" - option: first_run value: "{{ first_run }}" - option: local_tz diff --git a/roles/1-prep/tasks/raspberry_pi.yml b/roles/1-prep/tasks/raspberry_pi.yml index 11b23e651..5253fb95a 100644 --- a/roles/1-prep/tasks/raspberry_pi.yml +++ b/roles/1-prep/tasks/raspberry_pi.yml @@ -37,7 +37,7 @@ path: /etc/dphys-swapfile regexp: "^CONF_SWAPSIZE" line: "CONF_SWAPSIZE={{ pi_swap_file_size }}" - when: is_debuntu | bool # Redundant, given raspberry_pi.yml is only run when rpi_model: "rpi" (similar to is_rpi: True). Until someone tries a non-debuntu OS on RPi? + when: is_debuntu | bool # Redundant, given raspberry_pi.yml is only run when rpi_model: != "none" Until someone tries a non-debuntu OS on RPi? - name: Restart swap service "dphys-swapfile" (debuntu) #command: /etc/init.d/dphys-swapfile restart diff --git a/scripts/local_facts.fact b/scripts/local_facts.fact index 40d6bec1d..bc16645f3 100755 --- a/scripts/local_facts.fact +++ b/scripts/local_facts.fact @@ -56,6 +56,12 @@ else XO_VERSION="none" fi +if [ -f /proc/device-tree/model ]; then + RPI_VERSION=`cat /proc/device-tree/model` +else + RPI_VERSION="none" +fi + ANSIBLE_VERSION=$(ansible --version|head -n 1|cut -f 2 -d " ") if [ ! x$DHCPCD_PATH = x ]; then @@ -77,6 +83,7 @@ cat <