So, what if you need to determine EXACTLY which sort of Raspberry Pi you are working with?

Perhaps you are running an ansible playbook that is making a network map in order to document which devices are located where. Of course, there are many ways to accomplish this, but I like simplicity and this script gets the job done for me (though I might gather a bit more data than this particular script outputs). Yes, it’s possible to do this locally with an ansible gather facts, but I haven’t gotten around to that part yet (I’m currently working on another issue and, since time is a valuable commodity, I chose this path.) As with everything, I’m always open to suggestions for improvement.

Here’s a little bash script and data file that ansible (or what have you) can push to the device that will output specifically defined output data (see code snippet).

You can find the script and the data file on my github open repository: REQUIRES:


revString=`grep $( cat /proc/cpuinfo | grep Revision | awk '{ print $3 }' | tr "[a-z]" "[A-Z]" ) "$dataFile"`
[[ ! $revString = '' ]] && echo 'RasPi Type Found: ' || { echo 'RasPi Type not found: EXITING' && exit; }
raspiType=`echo "$revString" | cut -d ':' -f1`
raspiMem=`echo "$revString" | cut -d ':' -f2`
echo 'RasPi Type: '$raspiType
echo 'RasPi Mem: '$raspiMem

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>