{"version":"1.0","type":"rich","title":"ansible postgres playbook with PostGIS on Ubuntu, setting up postgis_template and creating databases from this postgis_template","description":"This example shows an Ansible playbook that provisions a PostgreSQL server with PostGIS on Ubuntu, creating a reusable `postgis_template` database and then generating multiple databases from that template. It first installs packages via the `apt` module, then uses the `postgresql_db` module and raw `psql` commands to initialize the template with PostGIS extensions and SQL scripts. The playbook also copies configuration files like `postgresql.conf` and `pg_hba.conf`, and creates named databases using `createdb -T postgis_template`, with user access managed through `postgresql_user`. The code references a `vars.yml` file for `$db_names` and `$db_user`, and includes a handler to restart PostgreSQL.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-5097702?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}