Search code examples
postgresqlpuppetredhatyum

Puppet include all repositories before installing package


i'm trying to install postgresql from puppetlabs package, but i need that will use my own package on my own repository. So i'm able to specify which package should install, which service name will have and so on. Then i'm going to erase all repos from the server and let puppet install all repos. That's what i think things should works:

node name { 
 include repos::internal::blabla
 class {'database':
 someparameters=>somevalue,
}

So this code in my mind should install all repos before the database, but even if i use require repos::...... isn't working anyway. That's what i got:

Debug: Prefetching yum resources for package
Debug: Executing '/bin/rpm --version'
Debug: Executing '/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n''
Debug: Executing '/bin/rpm -q postgresql91 --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Debug: Executing '/usr/bin/yum -d 0 -e 0 -y list postgresql91'
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list postgresql91' returned 1: Error: No matching Packages to list
Error: /Stage[main]/Postgresql::Client/Package[postgresql-client]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list postgresql91' returned 1: Error: No matching Packages to list
Debug: Executing '/bin/rpm -q postgresql91-server --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Debug: Executing '/usr/bin/yum -d 0 -e 0 -y list postgresql91-server'
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list postgresql91-server' returned 1: Error: No matching Packages to list
Error: /Stage[main]/Postgresql::Server::Install/Package[postgresql-server]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list postgresql91-server' returned 1: Error: No matching Packages to list
Debug: Prefetching inifile resources for yumrepo
Notice: /Stage[main]/Repos::Internal::Integration/Yumrepo[official-repository]/ensure: created
Info: changing mode of /etc/yum.repos.d/official-repository.repo from 600 to 644
Debug: /Stage[main]/Repos::Internal::Integration/Yumrepo[official-repository]: The container Class[Repos::Internal::Integration] will propagate my refresh event
Notice: /Stage[main]/Repos::Internal::Integration/Yumrepo[commonfor91]/ensure: created
Info: changing mode of /etc/yum.repos.d/commonfor91.repo from 600 to 644
Debug: /Stage[main]/Repos::Internal::Integration/Yumrepo[commonfor91]: The container Class[Repos::Internal::Integration] will propagate my refresh event
Notice: /Stage[main]/Repos::Internal::Integration/Yumrepo[epel-6]/ensure: created
Info: changing mode of /etc/yum.repos.d/epel-6.repo from 600 to 644
Debug: /Stage[main]/Repos::Internal::Integration/Yumrepo[epel-6]: The container Class[Repos::Internal::Integration] will propagate my refresh event

What's wrong? Thanks in advance. I'm using puppet 3.7.3 on redhat.


Solution

  • The relationship between the classes is built, but this is insufficient, because relationships will not typically cross class include boundaries.

    Error: /Stage[main]/Postgresql::Server::Install/Package[postgresql-server]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list postgresql91-server' returned 1: Error: No matching Packages to list

    Please note that this package is dcalred by Class[postgresql::server::install] and not Class['database']. The former is directly or indirectly included by the latter. But ordering rules will not applied to included classes (it would be very hurtful to complex manifests if this were the case).

    To make the dependencies work at least in the scope of your own modules, try and use

    contain postgresql
    

    in your database module instead of

    include postgresql
    

    If you need to pass parameters to the postgresql module, consider doing this through Hiera.


    Original answer before update on 2015-01-02.

    There is a variety of ways to express what you want. One of the most straight forward ones:

    Yumrepo<| |> -> Class['database']
    

    Note that this will realize any virtual yumrepo resources you might be using. If this is unacceptable to you, you can get more selective.

    Class['repos::internal::blabla'] -> Class['database']
    

    The basis of this is the chaining operator. It should get you going in some way like those depicted above.