automation script for postgresql

Could you please help how can I run automation script for postgresql after installing postgresql on Ubuntu? I need to automatize DB preparation before using it (create table, insert data, alter permissions).

I need to do it with the current rights of the user.
E.g., I have the only user admin_ubuntu. He has all rights to run psql.
All scripts are written but how can I run the script? usually, I need to edit configs ( I believe, /etc/postgresql/9.1/main/pg_hba.conf). But I do not want to do it.

  • Docker vs Mysql local server SQLSTATE[HY000] [2003]
  • Iscsid not starting on a centos6 docker on MacOS host
  • How to deploy many instances of the same Docker image with unique database connection string
  • How to mount a device of host to host in a Docker container?
  • Docker container sending empty responses
  • Installation is not happening according to Docker file
  • So, what I need is just to run sql which will make a lot of things. How can I do it to run it? The problem is that I need to do a lot of things to allow to run sql when the OS is immaculate (empty).

    It will be made every time when the Ubuntu will have been installed.

  • Docker image is not listed though I built using maven docker plugin
  • Vagrant and docker Protocol error mounting directory windows 7
  • Cannot download docker images behind proxy : Timeout : Docker for Mac
  • Getting error when running mocha test with Xvfb and firefox headlessly in a docker container
  • Artifactory: “docker service create” does not work with images of 0 byte
  • How to run a new Jupyter Notebook file that's not part of a pre-built docker image in docker?
  • One Solution collect form web for “automation script for postgresql”

    you should be able to run shell provisioning – following is example of what you can do:

    # creating user
    sudo -u postgres psql -c "CREATE USER admin WITH PASSWORD 'password';"
    # creating new db if needed .. might need 2 (dev/test)
    createdb -U vagrant mydevdb
    
    # if you have more complex things you'll need to put that in a create_db.sql file and run the script as
    sudo -u postgres psql < create_db.sql
    

    The create_db.sql file can contain any CREATE TABLE statement

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.