I am aware of this question which talks about using SELECT PostGIS_full_version(); but this requires you have a database on which the postgis extension is installed. 
I am using a fabric to write a program to check if postgis (above a particular version) is installed on a server and if not, install it. Is this possible?