What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use a Chef InSpec profile to audit PostgreSQL in two layers: operating-system checks prove that the expected packages, service, account, process, listener, and configuration are present; a postgres_session check proves database state such as role privileges and login capability. The workflow below installs PostgreSQL from Ubuntu packages, creates a reusable profile, keeps version-dependent paths in attributes, checks pg_hba.conf, and runs locally or over SSH.

What this audit can prove

InSpec is an open-source testing framework for infrastructure compliance and policy checks. A PostgreSQL audit profile turns your requirements into repeatable controls that produce human-readable and machine-readable results. It is more useful than a one-time command session because the same controls can be run against a workstation, a server, or a remote Ubuntu target after each configuration change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Audit layer What it verifies Typical InSpec resource
Installation Required PostgreSQL package and minimum major version package
Service Unit exists, starts at boot, and is currently running service
Operating system postgres account and process ownership user, processes
Network Approved port, address, and transport protocol are listening port
Server configuration Logging and connection settings in postgresql.conf postgres_conf
Client authentication pg_hba.conf rules match the approved policy file, command
Database state Roles, privileges, login flags, or application-specific SQL results postgres_session

Keep the layers separate in your profile. A passing service check does not prove that an application role has the right privileges, and a successful SQL query does not prove that the host is listening only on an approved interface.

Prerequisites and version cautions

  • An Ubuntu host with sudo access. The procedure applies to Ubuntu generally; the detailed walkthrough commonly associated with this profile uses Ubuntu 18.04 and PostgreSQL 10 names.
  • Internet or an internal Ubuntu package mirror for installation.
  • Chef InSpec installed on the machine from which you will run the profile. Ubuntu is supported as both a runtime and a remote target.
  • For database-level controls, a PostgreSQL account whose credentials can be supplied securely at run time.

Package names, systemd unit names, configuration directories, authentication defaults, and supported InSpec releases change with the Ubuntu release and PostgreSQL major version. Treat every version-specific value in the examples as an attribute to confirm on the target rather than as a universal constant. The examples below use PostgreSQL 10 identifiers only where the Ubuntu 18.04 walkthrough does.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

Install PostgreSQL and verify its defaults

Install from Ubuntu packages

sudo apt update
sudo apt install postgresql

The Ubuntu package installs a cluster and supplies viable defaults. On current Ubuntu documentation, local connections default to peer authentication, while host (TCP) connections default to scram-sha-256. Confirm the actual files on your release before encoding those values as policy; older releases and upgraded clusters can differ.

Check the service and cluster

sudo systemctl status postgresql
sudo systemctl is-enabled postgresql
sudo systemctl is-active postgresql
pg_lsclusters

pg_lsclusters is useful on Ubuntu because it shows the cluster version, name, port, status, data directory, and log file. If your installation uses a versioned unit such as postgresql@10-main, use that unit in the InSpec control instead of the umbrella postgresql service.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Confirm authentication behavior without weakening it

Inspect the active host-based authentication file and test through the same local or TCP path that applications use. Do not replace peer or encrypted host authentication merely to make a test pass. The Ubuntu documentation also shows a hostssl rule that rejects non-SSL TCP connections; its example certificate is for testing, so production deployments should use a certificate chain signed by a trusted authority.

Install InSpec and create a profile

Install and invoke InSpec

Install a supported InSpec release using the package method documented by the project for Ubuntu, then verify the executable:

inspec version
inspec help exec

Keep the InSpec version under your normal change-control process. Resource behavior and licensing terms can change, so validate the release you standardize on against the Ubuntu versions you operate.

Generate the profile skeleton

inspec init profile PostgreSQL
cd PostgreSQL
find . -maxdepth 2 -type f -print

A minimal profile contains inspec.yml and a controls/ directory. Put controls in a file such as controls/postgresql.rb. Use a meaningful profile name and description in inspec.yml so reports identify the purpose and owner.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make paths and names attributes

Do not hard-code the configuration directory throughout Ruby controls. Define the values once and override them per platform, image, or cluster:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
name: PostgreSQL

title: PostgreSQL compliance profile
maintainer: Platform Security
version: 1.0.0

attributes:
  - name: postgres_package
    type: string
    default: postgresql-10
  - name: postgres_service
    type: string
    default: postgresql@10-main
  - name: postgres_conf_dir
    type: string
    default: /etc/postgresql/10/main
  - name: postgres_port
    type: integer
    default: 5432
  - name: postgres_listen_address
    type: string
    default: 127.0.0.1

For another PostgreSQL major version, set the package, unit, and directory attributes to the values installed on that host. If a distribution uses a different layout, override the attributes rather than forking every control.

Audit package installation and service state

Package and minimum version

The package resource can assert both installation and a minimum version. The comparison is against the package version reported by Ubuntu, not a claim about the newest PostgreSQL release available upstream.

control 'postgresql-installation' do
  impact 1.0
  title 'Audit PostgreSQL installation'
  desc 'The approved PostgreSQL package is installed at the required version.'

  describe package(attribute('postgres_package')) do
    it { should be_installed }
    its('version') { should cmp >= '10' }
  end
end

Set the package and minimum version to your approved baseline. A control that expects postgresql-10 will fail on a host intentionally running another major version unless its attributes are changed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enabled and running service

control 'postgresql-service' do
  impact 1.0
  title 'Audit PostgreSQL service state'

  describe service(attribute('postgres_service')) do
    it { should be_installed }
    it { should be_enabled }
    it { should be_running }
  end
end

Some Ubuntu installations expose a generic postgresql unit and manage the actual cluster with a versioned unit. Audit the unit that owns the cluster you intend to protect. If the service is disabled intentionally for a standby or maintenance host, encode that exception as a separate profile input rather than silently removing the assertion.

Check the operating-system account and PostgreSQL process

Verify the service account

control 'postgresql-account' do
  impact 1.0
  title 'Audit the PostgreSQL operating-system account'

  describe user('postgres') do
    it { should exist }
    its('shell') { should_not eq '/bin/bash' }
  end
end

The existence check is the essential assertion. The shell check is optional and should match your hardening standard; some organizations deliberately assign a different non-login shell.

Verify process ownership

control 'postgresql-process' do
  impact 1.0
  title 'Audit PostgreSQL process ownership'

  describe processes('postgres') do
    it { should exist }
    its('users') { should include 'postgres' }
  end
end

Process names can vary by packaging and executable path. If your host reports a different name, discover it with ps -ef or pgrep -a postgres and set a profile attribute or adjust the resource selector. The purpose is to ensure the server is not running as an unexpected privileged account.

Audit the network listener

A running service can still expose an unsafe network surface. Check the approved port, address, and protocol together:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
control 'postgresql-listener' do
  impact 1.0
  title 'Audit the PostgreSQL network listener'

  describe port(attribute('postgres_port')) do
    it { should be_listening }
    its('addresses') { should include attribute('postgres_listen_address') }
    its('protocols') { should include 'tcp' }
  end
end

Use the address policy that matches your design. A loopback-only listener is appropriate for a database used only by local applications; a private interface or approved subnet may be required for an application tier. If PostgreSQL listens on multiple addresses, test the complete approved set and separately flag unexpected listeners. Also check that host-based authentication rules restrict the same network ranges; a listener check alone cannot enforce authorization.

Check postgresql.conf with postgres_conf

Keep the configuration directory portable

The postgres_conf resource reads PostgreSQL settings from the configuration directory. Ubuntu 18.04 examples use /etc/postgresql/10/main, but the path differs by operating system and major version. Build the path from the attribute:

control 'postgresql-logging' do
  impact 1.0
  title 'Audit PostgreSQL connection logging'

  describe postgres_conf(attribute('postgres_conf_dir')) do
    its('log_connections') { should eq 'on' }
    its('log_disconnections') { should eq 'on' }
    its('log_duration') { should eq 'on' }
  end
end

Use the values required by your policy. The same resource can test any PostgreSQL configuration option, including connection behavior and other logging settings. Pay attention to PostgreSQL’s accepted representations: a setting may be returned as on/off, a number, or a quoted string depending on the parameter.

Confirm which file is active

Ubuntu may include additional configuration fragments, and an administrator can change the active file location. Before relying on a path, identify the running cluster’s configuration with PostgreSQL tooling or the cluster metadata shown by pg_lsclusters. If a setting is managed through an include file, make the control inspect the effective source your change process owns, or add a database-level query for the effective value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Audit client authentication in pg_hba.conf

Authentication rules are order-sensitive: PostgreSQL uses the first matching line. A secure-looking rule later in the file does not protect a connection that already matched an earlier broad rule.

Check file ownership and mode

control 'postgresql-hba-file' do
  impact 1.0
  title 'Audit pg_hba.conf ownership and permissions'

  hba = "#{attribute('postgres_conf_dir')}/pg_hba.conf"

  describe file(hba) do
    it { should exist }
    its('owner') { should eq 'postgres' }
    its('group') { should eq 'postgres' }
    its('mode') { should cmp <= '0640' }
  end
end

Ownership and mode requirements vary by package and local policy. If Ubuntu assigns a different group or mode on your release, set the approved value rather than treating the example as universal.

Inspect rules, not just one substring

For a small, tightly controlled file, a command or file control can assert that required rules exist and forbidden broad rules are absent. Avoid a naïve substring test that can match a commented line or the wrong column. A practical approach is to remove comments, split fields, and compare normalized records:

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
control 'postgresql-hba-policy' do
  impact 1.0
  title 'Audit PostgreSQL client authentication rules'

  hba = "#{attribute('postgres_conf_dir')}/pg_hba.conf"
  describe command("awk '!/^([[:space:]]*#|[[:space:]]*$)/ {print}' #{hba}") do
    its('stdout') { should match(/^[[:space:]]*local[[:space:]]+all[[:space:]]+all[[:space:]]+peer([[:space:]]|$)/) }
    its('stdout') { should match(/^[[:space:]]*host[[:space:]]+all[[:space:]]+all[[:space:]]+[^[:space:]]+[[:space:]]+scram-sha-256([[:space:]]|$)/) }
  end
end

Use your actual database names, role names, CIDR ranges, and TLS requirements in these expressions. Current Ubuntu documentation describes peer for local connections and scram-sha-256 for host connections, but a production policy may require narrower ranges, named roles, or hostssl rules that reject unencrypted TCP. Test the rule order with representative connection attempts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use postgres_session for database-level assertions

Host resources cannot prove catalog state. To test whether an application role can log in, owns an object, or has a prohibited privilege, create a PostgreSQL session and query the catalog or an approved test view.

Supply credentials as attributes

attributes:
  - name: db_user
    type: string
    default: postgres
  - name: db_password
    type: string
    required: true
  - name: db_host
    type: string
    default: 127.0.0.1
  - name: db_port
    type: integer
    default: 5432

Do not commit a real password to inspec.yml or the control file. Inject it through your secret store, an ephemeral attribute file with restricted permissions, or the execution mechanism used by your CI system. Ensure command output and InSpec reports do not echo the credential.

Query role login capability

control 'postgresql-roles' do
  impact 1.0
  title 'Audit application role login capability'

  sql = postgres_session(
    attribute('db_user'),
    attribute('db_password'),
    attribute('db_host'),
    attribute('db_port')
  )

  describe sql.query(
    "SELECT rolcanlogin FROM pg_roles WHERE rolname = 'app_user';",
    ['postgres']
  ) do
    its('rows.first.rolcanlogin') { should eq true }
  end
end

The session constructor accepts username, password, host, port, and an optional socket path. Use a socket when the policy intentionally tests local peer or socket behavior; use a host and port when you need to test TCP authentication. Query only the columns and rows needed for the assertion, and handle a missing role explicitly so an empty result cannot be mistaken for success.

Examples of useful SQL checks

  • Confirm that an application role exists and has rolcanlogin set as intended.
  • Check membership in approved roles through PostgreSQL catalog views.
  • Detect superuser or replication privileges that are forbidden for application accounts.
  • Assert an application-specific setting or extension is present in the intended database.

Database queries require a connection that can read the relevant catalog information. If the audit account lacks permission, treat that as a credential or authorization finding rather than changing production privileges solely for the test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Build a complete control file

The following compact profile demonstrates how the layers fit together. Split it into multiple files when different teams own host, configuration, and database controls.

control 'postgresql-installation' do
  impact 1.0
  title 'Audit PostgreSQL installation'
  describe package(attribute('postgres_package')) do
    it { should be_installed }
    its('version') { should cmp >= '10' }
  end
end

control 'postgresql-service' do
  impact 1.0
  title 'Audit PostgreSQL service'
  describe service(attribute('postgres_service')) do
    it { should be_installed }
    it { should be_enabled }
    it { should be_running }
  end
end

control 'postgresql-runtime' do
  impact 1.0
  title 'Audit PostgreSQL account, process, and listener'
  describe user('postgres') { it { should exist } }
  describe processes('postgres') do
    it { should exist }
    its('users') { should include 'postgres' }
  end
  describe port(attribute('postgres_port')) do
    it { should be_listening }
    its('protocols') { should include 'tcp' }
  end
end

control 'postgresql-configuration' do
  impact 1.0
  title 'Audit PostgreSQL logging configuration'
  describe postgres_conf(attribute('postgres_conf_dir')) do
    its('log_connections') { should eq 'on' }
    its('log_disconnections') { should eq 'on' }
    its('log_duration') { should eq 'on' }
  end
end

Add the authentication and SQL controls separately so a report clearly identifies whether a failure concerns the operating system, server configuration, access policy, or database catalog.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Run the profile locally or over SSH

Local execution

cd PostgreSQL
inspec exec .

Use elevated execution when controls need to read root-owned configuration files or inspect privileged process information:

inspec exec . --sudo

Run a focused control while developing:

inspec exec . --controls postgresql-hba-policy

Remote Ubuntu execution

inspec exec . -t ssh://audit@db01.example.internal --sudo

Use your organization’s SSH key, bastion, host-key verification, and privilege-escalation settings. The remote account needs enough access for the selected controls; database-level checks still need PostgreSQL credentials that can connect from the execution context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pass environment-specific attributes

Override package names, paths, ports, and credentials without editing the profile. For example, provide a protected attribute file for a PostgreSQL 14 cluster whose configuration directory is different from the Ubuntu 18.04 example, then run the same command with that file. Keep secret files outside source control and delete temporary copies after execution.

Interpret failures and remediate safely

Failure category Likely cause Safe next check
Package or version Wrong major version, incomplete package installation, or stale attribute Compare dpkg -l and apt-cache policy with the approved baseline; update the attribute only if the version is intentional.
Service Cluster unit differs, service is stopped, or startup is disabled Run systemctl status on the exact unit and inspect journal output before restarting.
Process/account Process selector does not match the package, or ownership is unsafe Inspect ps -ef; correct the selector or investigate why PostgreSQL is not running as the expected account.
Listener Port, address, or protocol differs from policy Check effective listen_addresses, firewall rules, and ss -ltnp; do not broaden the listener merely to satisfy a test.
Configuration Wrong directory, include file, spelling, or value representation Confirm the active cluster path and effective setting, then change the managed configuration and reload deliberately.
Authentication Rule order, broad CIDR, cleartext method, or missing TLS requirement Normalize active lines, test representative local and TCP connections, and tighten the earliest matching rule.
SQL session Bad credentials, unreachable socket, missing permission, or unexpected catalog state Test the same connection parameters with a controlled client and grant only the minimum audit visibility required.

After a remediation, rerun the affected control and then the complete profile. A profile should report the remaining policy gap, not conceal it through a local exception.

Design choices for a maintainable audit

Choice Less maintainable approach Preferred approach
Coverage Only check that the service is running Combine host, configuration, authentication, and SQL controls.
Portability Repeat /etc/postgresql/10/main in every control Store paths, package names, units, and ports as profile attributes.
Credentials Embed a password in Ruby or source control Inject secrets at runtime and restrict report/log exposure.
Connectivity Test only the local socket Choose local or TCP deliberately and include SSH execution for remote hosts.
Authentication policy Search for an unanchored text fragment Parse active rules, account for first-match order, and test representative clients.
Remediation Change settings until the test turns green Map each failure to an approved owner and change record, then rerun.

Operational checklist

  • Record the Ubuntu release, PostgreSQL major version, cluster name, service unit, port, and configuration directory used for the run.
  • Set the profile attributes to those discovered values; do not assume PostgreSQL 10 names on a newer or older cluster.
  • Run package, service, account, process, and listener controls before attempting SQL assertions.
  • Verify the effective pg_hba.conf order and test both local and TCP authentication paths required by applications.
  • Use postgres_conf for server settings and postgres_session for catalog state; neither replaces the other.
  • Run locally with inspec exec ., add --sudo only when required, and use SSH targets for remote Ubuntu hosts.
  • Store credentials outside the profile and review generated reports for accidental secret disclosure.
  • Re-run the complete profile after upgrades, cluster moves, authentication changes, or network-listener changes.

Frequently Asked Questions

Does this profile work unchanged on every Ubuntu release?

No. Package names, systemd units, configuration paths, authentication defaults, and InSpec support vary. Use attributes and confirm the active cluster values on each target.

Can host-level InSpec resources verify PostgreSQL role privileges?

No. Use postgres_session with a securely supplied credential and targeted SQL queries for roles, memberships, and other catalog state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I use the generic postgresql service or a versioned unit?

Audit the unit that actually owns the cluster. Ubuntu may expose an umbrella service while the running cluster is managed by a unit such as postgresql@10-main.

Why did an authentication control pass even though a later rule is stricter?

PostgreSQL applies the first matching pg_hba.conf rule. Check active rule order and remove or narrow an earlier broad rule.

When is --sudo necessary?

Use it when controls must read root-owned files or inspect information unavailable to the execution user. Database credentials and SSH authentication remain separate concerns.

The Bottom Line

A reliable Ubuntu PostgreSQL audit combines version-aware host controls with explicit authentication and database-session checks. Parameterize paths and service names, protect credentials, and treat every failed control as a specific remediation task rather than a reason to weaken the policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.