I have a requirement to create the users in PostgreSQL DB using Jenkins pipeline. It will be greatly appreciated if someone could share reliable links. Currently I am stuck on how to start.
I am a newbie in Jenkins.
To connect Jenkins with a PSQL Database, you would first need to setup psql driver plugin in jenkins. You can add the plugin & manage the configuration from the Jenkins Setup.
Once you are done with this, the best way to interact with the db would be to write the commands you need to execute in a shell script file, like $HOME/db_scripts/add_user.sh which you can execute from the jenkins directly.
Hope this answers your question!
Related
This question already has answers here:
Export and import table dump (.sql) using pgAdmin
(6 answers)
Closed 1 year ago.
Let I first state that I am not a DBA-guy but I do have a question regarding restoring remote databases using PG Admin.
I have this PG Admin tool (v4.27) running in a Docker container and I use this portal to maintain two separate Postgress databases, both running in a Docker container as well. I installed PG Agent in both database containers and run scheduled daily backup's, defined via PG Admin and stored in the container of each corresponding databases. So far so good.
Now I want to restore one of these databases by using the latest daily backup file (*.sql), but the Restore Dialog of PG Admin only looks for files stored locally (the PG Admin container)?
Whatever I tried or searched for on the internet, to me it seems not possible to show a list of remote backup files in PG Admin or run manually a remote SQL file. Is this even possible in PG Admin? Running psql in the query editor is not possible (duh ...) and due to not finding the remote SQL-restore file I have no clue how to run this code within PG Admin on the remote corresponding database container.
The one and only solution so far I can think of, is scheduling a restore which has no calendar and should be triggered manually when needed, but it's not the prettiest solution.
Do I miss something or did I overlook the right documentation or have I created a silly, unmaintainable solution?
Thanks in advance for thinking along and kind regards,
Aad Dijksman
You cannot restore a plain format dump (an SQL script) with pgAdmin. You will have to use psql, the command line client.
COPY statements and data are mixed in such a dump, and that would make pgAdmin choke.
The solution by #Laurenz Albe points out that it is best to use the command line psql here, and that would be my first go-to.
However, if for whatever reason you don't have access to the command line and are only able to connect to this database via pgadmin, there is another solution which you can find here:
Export and import table dump (.sql) using pgAdmin
I recommend looking at the solution by Tomas Greif.
Is there an official way of installing an extension on a GCP Postgress Cloud SQL instance via Terraform?
Closest I've found is this unofficial Postgres resource but it's not immediately clear how to link the two. This issue on their tracker sort of shows how, but far from a step by step guide.
if it makes any difference, I'm trying to provision a Postgres Cloud SQL instance with PostGIS.
Thanks.
Terraform is a deployment tool, to create all your infrastructure. To install an extension on Postgres, you need a installation tool, because you need to connect to the database and to run a command.
It's the same thing if you want to create a user in the database and you want to grant some privileges on it.
In summary, you can't achieve that with Terraform. I recommend you to have an installation tool, such as Ansible to perform this action.
An alternative is to create, with Terraform, a micro VM with a startup script that connect the database, run the command and destroy itself at the end.
I´ve created a MongoDB instance using the Google Click to Deploy VM and I've added a firewall rule 0.0.0.0/0 and works fine using dataGrip or connecting from outside. But now I want to create an user account for obvious reasons and I don't know how to do it.
I've done it locally installing MongoDB and executing the command db.createUser(... but I don't know how to connect to the mongo db in google cloud and execute the same command in order to create the account.
Thanks and sorry my bad english.
I haven't used the click to deploy like you're describing, but my guess is, if you go here:
https://console.cloud.google.com/compute/instances
The instance that was created for you shows up, and in the row for the instance, look for the column that says Connect, you'll see a button that says SSH. Clicking that will open a window that will connect you to the VM. It should have the MongoDB client installed and you can run commands there as if you had installed it locally and create your user.
I'm working with an Azure Postgresql database and am using the Cloud Shell to run psql scripts without problems. I'm now trying to load some shp files via the shp2pgsql command. The cloud shell responds by:
bash: shp2pgsql: command not found
Is it possible at all to use shp2pgsql with the Cloud Shell or I'm missing something? I've already successfully created the postgis extension on the Postgresql server.
Unfortunately, it seems that you cannot run the shp2pgsql command in the Azure Cloud Shell. It is just an interactive, browser-accessible shell for managing Azure resources. Not integrated with too much tool in it because of its flexibility. You can get more details about the features from the Features & tools for Azure Cloud Shell.
I suggest if you want to do something complicated, you'd better run it in a specific Azure VM for yourself. Hope this will be helpful to you.
i am trying to install jboss-fuse-6.1.0.redhat-379
and i am able to create esb:create-admin-user via console but not i am trying to automate installation via shell script .
i am able to start fuse server but not able to create user
esb:create-admin-user.
below is sample script for creating user.
!/bin/ksh
cd $HOME/jboss-fuse-6.1.0.redhat-379/bin
./fuse esb:create-admin-user --new-user admin1 --new-user-password admin12
but it is not creating user.
please let me know how i can do this .
This could be the issue with file write access present in etc .
Here is the another solution for that
Go to jboss-fuse-6.1.0.redhat-379/etc folder
Open users.properties file and add username=password,admin
Last word admin is the "Admin" role.
You are probably looking for the bin/client script to execute commands against a running fuse instance. But for that you will need a username/password ;)
If you want to automate it is indeed probably easier just to use #mahesh-biradar approach:
echo "admin1=admin12,admin" >> etc/users.properties