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.

  • Are there disadvantages when running a docker base image that differs from my distribution?
  • Docker link container - environment variables not being displayed
  • User permissions not changing on docker hub
  • Start a docker machine using JavaScript
  • How to assign domain names to containers in docker
  • Can I mix linux-based and windows-based containers in same docker engine host?
  • 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.

  • Testing ansible playbook with systemd services in docker
  • cannot connect to docker on RemoteServer using Ansible
  • How to define OpenJDK 8 in CentOS based Dockerfile?
  • Use custom Visual Studio run configuration with Docker
  • What benefits does Docker Compose have over Docker Swarm and Docker Stack?
  • Docker - only image with operating system?
  • 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.