Created
October 16, 2012 17:43
-
-
Save gregsymons/3900805 to your computer and use it in GitHub Desktop.
Creating a postgis template database in chef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Mon, 15 Oct 2012 22:45:22 +0000] DEBUG: Processing execute[create-postgis-template-db] on vagrant.vm | |
[Mon, 15 Oct 2012 22:45:22 +0000] INFO: Processing execute[create-postgis-template-db] action run (postgis::server line 25) | |
[Mon, 15 Oct 2012 22:45:22 +0000] DEBUG: Skipping execute[create-postgis-template-db] due to not_if command ` PGPASSWORD=R3n41rAfFMQzoOghaAYV psql -d postgis -U postgres >/dev/null 2&>1 | |
` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POSTGRES_CREDS = { | |
'PGPASSWORD' => Chef::Config[:solo] ? | |
File.read('/etc/postgresql/9.1/main/.org_grok').strip | |
: node[:postgresql][:password], | |
'PGUSER' => 'postgres', | |
} | |
#ideally, this would be done using the database cookbook. Unfortunately, that's | |
#broken on an omnibus install. Which of course, is what we use. | |
execute 'create-postgis-template-db' do | |
environment POSTGRES_CREDS | |
command <<-EOC | |
createdb postgis | |
createlang plpgsql postgis | |
psql -d postgis -f /usr/share/postgresql-9.1/contrib/postgis-1.5/postgis.sql | |
psql -d postgis -f /usr/share/postgresql-9.1/contrib/postgis-1.5/spatial_ref_sys.sql | |
EOC | |
not_if <<-EOC | |
PGPASSWORD=#{node[:postgresql][:password]} psql -d postgis -U postgres >/dev/null 2&>1 | |
EOC | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@vagrant:~$ PGPASSWORD=R3n41rAfFMQzoOghaAYV psql -d postgis -U postgres >/dev/null 2&>1 && echo yes || echo no | |
no | |
vagrant@vagrant:~$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment