From 214aa1b7d9c367137d40c1f329fb141453ca7099 Mon Sep 17 00:00:00 2001 From: Anton Kettling <27301962+wandt0n@users.noreply.github.com> Date: Tue, 30 Jul 2024 22:09:48 +0200 Subject: [PATCH 1/4] use parameter host_ip This ensures that the server is only accessible to localhost (as it should be. It still uses postgres 9.4!) --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 0125a69..2e29cf5 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,5 +18,5 @@ Vagrant::Config.run do |config| config.vm.provision :shell, :path => "Vagrant-setup/bootstrap.sh" # PostgreSQL Server port forwarding - config.vm.forward_port 5432, 15432 + config.vm.forward_port 5432, 15432, host_ip: "127.0.0.1" end From 610cc2e9622b8eb1595800552b25b4482b7641bd Mon Sep 17 00:00:00 2001 From: Anton Kettling <27301962+wandt0n@users.noreply.github.com> Date: Tue, 30 Jul 2024 22:10:23 +0200 Subject: [PATCH 2/4] Updated to configuration version 2 format Tested on vagrant v2.3.7 --- Vagrantfile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 2e29cf5..5462d30 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -7,16 +7,14 @@ date > /etc/vagrant_provisioned_at SCRIPT Vagrant.configure("2") do |config| - config.vm.provision "shell", inline: $script -end - -Vagrant::Config.run do |config| config.vm.box = "ubuntu/trusty64" - config.vm.host_name = "postgresql" + config.vm.hostname = "postgresql" - config.vm.share_folder "bootstrap", "/mnt/bootstrap", ".", :create => true - config.vm.provision :shell, :path => "Vagrant-setup/bootstrap.sh" + config.vm.synced_folder ".", "/mnt/bootstrap", create: true + config.vm.provision "shell", inline: $script + config.vm.provision "shell", path: "Vagrant-setup/bootstrap.sh" + # PostgreSQL Server port forwarding - config.vm.forward_port 5432, 15432, host_ip: "127.0.0.1" + config.vm.network "forwarded_port", guest: 5432, host: 15432, host_ip: "127.0.0.1" end From eebe401deeedf54c40c1072ebc58da3c54555da8 Mon Sep 17 00:00:00 2001 From: Anton Kettling <27301962+wandt0n@users.noreply.github.com> Date: Tue, 30 Jul 2024 22:14:55 +0200 Subject: [PATCH 3/4] Documentation To my knowledge (and testing), the port that should be used by the commands mentioned here is actually 5432 --- Vagrant-setup/bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Vagrant-setup/bootstrap.sh b/Vagrant-setup/bootstrap.sh index 4b81b18..562dba3 100755 --- a/Vagrant-setup/bootstrap.sh +++ b/Vagrant-setup/bootstrap.sh @@ -31,10 +31,10 @@ print_db_usage () { echo " PGUSER=$APP_DB_USER PGPASSWORD=$APP_DB_PASS psql -h localhost $APP_DB_NAME" echo "" echo "Env variable for application development:" - echo " DATABASE_URL=postgresql://$APP_DB_USER:$APP_DB_PASS@localhost:15432/$APP_DB_NAME" + echo " DATABASE_URL=postgresql://$APP_DB_USER:$APP_DB_PASS@localhost:5432/$APP_DB_NAME" echo "" echo "Local command to access the database via psql:" - echo " PGUSER=$APP_DB_USER PGPASSWORD=$APP_DB_PASS psql -h localhost -p 15432 $APP_DB_NAME" + echo " PGUSER=$APP_DB_USER PGPASSWORD=$APP_DB_PASS psql -h localhost -p 5432 $APP_DB_NAME" } export DEBIAN_FRONTEND=noninteractive From 0f350e9aba9ec51a9ef9bb21e312b12144eece88 Mon Sep 17 00:00:00 2001 From: Anton Kettling <27301962+wandt0n@users.noreply.github.com> Date: Tue, 30 Jul 2024 22:16:37 +0200 Subject: [PATCH 4/4] Fixed links to postgres repos Updated it to work with the current repository structure of postgres --- Vagrant-setup/bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Vagrant-setup/bootstrap.sh b/Vagrant-setup/bootstrap.sh index 562dba3..d77ceb6 100755 --- a/Vagrant-setup/bootstrap.sh +++ b/Vagrant-setup/bootstrap.sh @@ -53,10 +53,10 @@ PG_REPO_APT_SOURCE=/etc/apt/sources.list.d/pgdg.list if [ ! -f "$PG_REPO_APT_SOURCE" ] then # Add PG apt repo: - echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > "$PG_REPO_APT_SOURCE" + echo "deb http://apt-archive.postgresql.org/pub/repos/apt/ trusty-pgdg main" > "$PG_REPO_APT_SOURCE" # Add PGDG repo key: - wget --quiet -O - https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - fi # Update package list and upgrade all packages