class postgresql {
  contain postgresql::install

  contain postgresql::pgadmin
}

class postgresql::install {
  # https://www.postgresql.org/download/linux/debian/
  package { 'postgresql-common':
    ensure => installed
  } ~> 
  exec { 'postgresql-install':
    command     => '/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y',
    refreshonly => true,
  } ~> 
  exec { 'postgresql-apt-update':
    command     => 'apt update',
    path => ['/usr/bin'],
    refreshonly => true,
  } ~>
  package { 'postgresql-16':
    ensure => installed
  } ~>
  package { 'postgresql-client-16':
    ensure => installed
  }
}

class postgresql::service {
  service { 'postgresql':
    ensure => running,
    enable => true
  }
}
