Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to install specific postgres version on Rocky Linux 8 #1398

Open
hertell opened this issue Feb 12, 2023 · 2 comments
Open

Failure to install specific postgres version on Rocky Linux 8 #1398

hertell opened this issue Feb 12, 2023 · 2 comments

Comments

@hertell
Copy link

hertell commented Feb 12, 2023

The issue

The following does not work on Rocky Linux 8 without first disabling the yum postgresql module.

  class { 'postgresql::globals':
    manage_package_repo => true,
    version             => '14',
  }->
  class { 'postgresql::server':
  }

It returns the following error

Error: Execution of '/bin/dnf -d 0 -e 1 -y install postgresql14-server' returned 1: Error: Unable to find a match: postgresql14-server
Error: /Stage[main]/Postgresql::Server::Install/Package[postgresql-server]/ensure: change from 'purged' to 'present' failed: Execution of '/bin/dnf -d 0 -e 1 -y install postgresql14-server' returned 1: Error: Unable to find a match: postgresql14-server (corrective)
Notice: /Stage[main]/Postgresql::Server::Initdb/File[/var/lib/pgsql/14/data]: Dependency Package[postgresql-server] has failures: true
Warning: /Stage[main]/Postgresql::Server::Initdb/File[/var/lib/pgsql/14/data]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Initdb/Exec[postgresql_initdb]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/File[/var/lib/pgsql/14/data/postgresql.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/File[systemd-conf-dir]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/File[systemd-override]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/File[old-systemd-override]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Exec[restart-systemd]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Concat[/var/lib/pgsql/14/data/pg_hba.conf]/Concat_file[/var/lib/pgsql/14/data/pg_hba.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Concat[/var/lib/pgsql/14/data/pg_hba.conf]/File[/var/lib/pgsql/14/data/pg_hba.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Concat[/var/lib/pgsql/14/data/pg_hba.conf]/Concat_fragment[/var/lib/pgsql/14/data/pg_hba.conf_header]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Config_entry[port]/Postgresql_conf[port]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Config_entry[data_directory]/Postgresql_conf[data_directory]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Concat[/var/lib/pgsql/14/data/pg_ident.conf]/Concat_file[/var/lib/pgsql/14/data/pg_ident.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Concat[/var/lib/pgsql/14/data/pg_ident.conf]/File[/var/lib/pgsql/14/data/pg_ident.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Concat[/var/lib/pgsql/14/data/pg_ident.conf]/Concat_fragment[/var/lib/pgsql/14/data/pg_ident.conf_header]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Pg_hba_rule[local access as postgres user]/Concat::Fragment[pg_hba_rule_local access as postgres user]/Concat_fragment[pg_hba_rule_local access as postgres user]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Pg_hba_rule[local access to database with same name]/Concat::Fragment[pg_hba_rule_local access to database with same name]/Concat_fragment[pg_hba_rule_local access to database with same name]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Pg_hba_rule[allow localhost TCP access to postgresql user]/Concat::Fragment[pg_hba_rule_allow localhost TCP access to postgresql user]/Concat_fragment[pg_hba_rule_allow localhost TCP access to postgresql user]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Pg_hba_rule[deny access to postgresql user]/Concat::Fragment[pg_hba_rule_deny access to postgresql user]/Concat_fragment[pg_hba_rule_deny access to postgresql user]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Pg_hba_rule[allow access to all users]/Concat::Fragment[pg_hba_rule_allow access to all users]/Concat_fragment[pg_hba_rule_allow access to all users]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Config/Postgresql::Server::Pg_hba_rule[allow access to ipv6 localhost]/Concat::Fragment[pg_hba_rule_allow access to ipv6 localhost]/Concat_fragment[pg_hba_rule_allow access to ipv6 localhost]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Service/Anchor[postgresql::server::service::begin]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Service/Service[postgresqld]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Service/Postgresql_conn_validator[validate_service_is_running]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Service/Anchor[postgresql::server::service::end]: Skipping because of failed dependencies
Warning: /Stage[main]/Postgresql::Server::Reload/Exec[postgresql_reload]: Skipping because of failed dependencies

To get it to work, i need to disable the yum postresql module first.

dnf -qy module disable postgresql

Working solution

The following snippet solves the issue, and i get postgres14 installed

  exec {"Disable yum postgresql module":
    path    => '/usr/bin:/usr/sbin:/bin',
    command => 'dnf -qy module disable postgresql',
    onlyif  => 'test $(dnf module list --enabled |grep postgresql|wc -l) -gt 0'
  }->
  class { 'postgresql::globals':
    manage_package_repo => true,
    version             => '14',
  }->
  class { 'postgresql::server':
  }

an other option could be.

  exec {"Disable dnf postgresql module":
    command => '/bin/dnf -qy module disable postgresql && /bin/touch /etc/.dnf-postgres-disabled',
    creates => '/etc/.dnf-postgres-disabled'
  }

This works quicker when not having to run dnf module list --enabled |grep postgresql|wc -l

@ekohl
Copy link
Collaborator

ekohl commented Feb 13, 2023

When I wrote dnf module management in 8d0efec I only considered using the system modules, not an external repo.

One workaround is to use the private module directly:

class { 'postgresql::dnfmodule':
  ensure => absent,
}

class { 'postgresql::globals':
  manage_package_repo => true,
  version             => '14',
} ->
class { 'postgresql::server':
}

A better thing would be to enhance globals here:

if $manage_dnf_module {
class { 'postgresql::dnfmodule':
ensure => $globals_version,
}
}

You could make it ensure the absence if manage_package_repo is true.

But please don't use exec since package with the dnfmodule provider is much cleaner.

@HT43-bqxFqB
Copy link

On Alma Linux 8 (elevated from CentOS 7) the same issue appears when using the external Postgresql repositories. When using the private postgresql::dnfmodule class, one could use the disabled value for ensure. But this conflicts with enable_only inside the postgresql::dnfmodule class, which is also not changeable... Thus, the Enum does not suit with other package parameters and there for using this code currently does not work with external repositories.

We've decided to copy the code into our own class without the enable_only => true and use that until this issue is fixed:

# postgresql dnf module needs to be disabled on EL >= 8
# see https://github.com/puppetlabs/puppetlabs-postgresql/issues/1398
if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] >= '8' {
    # based on https://github.com/puppetlabs/puppetlabs-postgresql/blob/main/manifests/dnfmodule.pp
    package { 'postgresql dnf module':
        ensure   => 'disabled',
        name     => 'postgresql',
        provider => 'dnfmodule',
    }

    Package['postgresql dnf module'] -> Package<|tag == 'puppetlabs-postgresql'|>
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants