cloud-init
allows customising and configuring deployed server instances on most popular cloud service providers easily without requiring the use of other related tools like Ansible. Since cloud-init
is such a reliable tool, this brief write-up will document the exact steps and procedures to install and setup PostgreSQL on a Debian 12 (Bookworm) server instance.
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --with-fingerprint --with-colons \
| awk -F: '/^fpr/ { print $10 }'
gpg --keyserver=keyserver.ubuntu.com --recv-keys <INSERT-KEY-ID-HERE>
Then copy the following contents to your "user-data" or "cloud-config" file or UI/UX on the portal.
#cloud-config
package_update: true
package_upgrade: true
groups:
- admin-group
- root
- ssh-users
users:
- default
- name: <INSERT-SSH-LOGIN-NAME>
gecos: <INSERT-SSH-ID-NAME-AND-EMAIL>
shell: /bin/bash
lock_passwd: true
group:
- ssh-users
- sudo
sudo:
- ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NT<snip>
apt:
sources:
postgresql:
keyid: <INSERT-KEY-ID-HERE>
source: deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main
packages:
- postgresql