FAQ
Hi,

Its probably a trivial issue or something I have missed.

I need to install a package provided the pillar condition is met.

  # salt medium77 pillar.get
pg_version

medium77:
     9.3

--snip--
pkgrepo:
   pkg:
     - installed
     - sources:
       {% if pillar.get('pg_version') == '9.3' %}
       - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
       {% endif %}
--snip--

When I run this I get following error message
--snip--
medium77:
----------
           ID: pkgrepo
     Function: pkg.installed
       Result: False
      Comment: The following package(s) were not found, and no possible
matches were found in the package db: pkgrepo
      Changes:

Summary
------------
Succeeded: 0
Failed: 1
------------
Total: 1
--snip--

The package does install without the if statement.

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Mike Shade at Jul 29, 2014 at 12:17 pm
    Is that pillar defined for the minion you are testing against? If not,
    you'll want to wrap the entire state in an if instead of just the pkgrepo
    source.

    On Tue, Jul 29, 2014 at 7:15 AM, wrote:

    Hi,

    Its probably a trivial issue or something I have missed.

    I need to install a package provided the pillar condition is met.

    # salt medium77 pillar.get
    pg_version

    medium77:
    9.3

    --snip--
    pkgrepo:
    pkg:
    - installed
    - sources:
    {% if pillar.get('pg_version') == '9.3' %}
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}
    --snip--

    When I run this I get following error message
    --snip--
    medium77:
    ----------
    ID: pkgrepo
    Function: pkg.installed
    Result: False
    Comment: The following package(s) were not found, and no possible
    matches were found in the package db: pkgrepo
    Changes:

    Summary
    ------------
    Succeeded: 0
    Failed: 1
    ------------
    Total: 1
    --snip--

    The package does install without the if statement.

    --
    You received this message because you are subscribed to the Google Groups
    "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Xavier Barbosa at Jul 29, 2014 at 1:46 pm
    9.3 is casted as a float. try:

         {% if pillar.get('pg_version') == 9.3 %}


    Le mardi 29 juillet 2014 13:15:49 UTC+2, t10t...@gmail.com a écrit :
    Hi,

    Its probably a trivial issue or something I have missed.

    I need to install a package provided the pillar condition is met.

    # salt medium77 pillar.get
    pg_version

    medium77:
    9.3

    --snip--
    pkgrepo:
    pkg:
    - installed
    - sources:
    {% if pillar.get('pg_version') == '9.3' %}
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}
    --snip--

    When I run this I get following error message
    --snip--
    medium77:
    ----------
    ID: pkgrepo
    Function: pkg.installed
    Result: False
    Comment: The following package(s) were not found, and no possible
    matches were found in the package db: pkgrepo
    Changes:

    Summary
    ------------
    Succeeded: 0
    Failed: 1
    ------------
    Total: 1
    --snip--

    The package does install without the if statement.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • T10tennn at Jul 29, 2014 at 6:59 pm
    Hi Xavier,

    That was it .. It did the trick , thanks .. it seems that postgres supplied
    rpm - pgdg-centos93-9.3-1.noarch.rpm
    has issues with pkg.install. It installs fine and probably exits with
    status code 1

    --snip--
       salt-call state.sls postgres.pkgrepo
    testing

    [INFO ] Loading fresh modules for state activity
    [INFO ] Fetching file from saltenv 'testing', ** done **
    'postgres/pkgrepo.sls'
    [INFO ] Running state [pkgrepo] at time 20:45:18.748542
    [INFO ] Executing state pkg.installed for pkgrepo
    [INFO ] Executing command 'repoquery
    --queryformat="%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-%{REPOID}"
    --all --pkgnarrow=installed' in directory '/root'
    [INFO ] Executing command 'yum -q clean expire-cache && yum -q
    check-update' in directory '/root'
    [INFO ] Executing command 'yum -y install
    /var/cache/salt/minion/extrn_files/testing/t10.local/pg/centos6/pgdg-centos93-9.3-1.noarch.rpm'
    in directory '/root'
    [INFO ] Executing command 'repoquery
    --queryformat="%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-%{REPOID}"
    --all --pkgnarrow=installed' in directory '/root'
    [ERROR ] Installed Packages:
    pgdg-centos93 changed from absent to 9.3-1

    [INFO ] Loading fresh modules for state activity
    [INFO ] Completed state [pkgrepo] at time 20:45:32.447152
    local:
    ----------
               ID: pkgrepo
         Function: pkg.installed
           Result: False
          Comment: The following packages failed to install/update: pgdg-93.
          Changes:
                   ----------
                   pgdg-centos93:
                       ----------
                       new:
                           9.3-1
                       old:


    Summary
    ------------
    Succeeded: 0
    Failed: 1
    ------------
    Total: 1
    --snip--


    If I run the same with
    --snip--
    salt-call pkg.install
    ftp://t10.local/pg/centos6/pgdg-centos93-9.3-1.noarch.rpm

    [INFO ] Executing command 'repoquery
    --queryformat="%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-%{REPOID}"
    --all --pkgnarrow=installed' in directory '/root'
    [INFO ] Executing command 'yum -y install
    ftp://t10.local/pg/centos6/pgdg-centos93-9.3-1.noarch.rpm' in directory
    '/root'
    [INFO ] Executing command 'repoquery
    --queryformat="%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-%{REPOID}"
    --all --pkgnarrow=installed' in directory '/root'
    local:
         ----------
         pgdg-centos93:
             ----------
             new:
                 9.3-1
             old:

    it works fine.
    On Tuesday, July 29, 2014 3:46:39 PM UTC+2, Xavier Barbosa wrote:

    9.3 is casted as a float. try:

    {% if pillar.get('pg_version') == 9.3 %}


    Le mardi 29 juillet 2014 13:15:49 UTC+2, t10t...@gmail.com a écrit :
    Hi,

    Its probably a trivial issue or something I have missed.

    I need to install a package provided the pillar condition is met.

    # salt medium77 pillar.get
    pg_version

    medium77:
    9.3

    --snip--
    pkgrepo:
    pkg:
    - installed
    - sources:
    {% if pillar.get('pg_version') == '9.3' %}
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}
    --snip--

    When I run this I get following error message
    --snip--
    medium77:
    ----------
    ID: pkgrepo
    Function: pkg.installed
    Result: False
    Comment: The following package(s) were not found, and no possible
    matches were found in the package db: pkgrepo
    Changes:

    Summary
    ------------
    Succeeded: 0
    Failed: 1
    ------------
    Total: 1
    --snip--

    The package does install without the if statement.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Wolodja Wentland at Jul 29, 2014 at 7:19 pm

    On Tue, Jul 29, 2014 at 04:15 -0700, t10tennn@gmail.com wrote:
    Its probably a trivial issue or something I have missed.
    I need to install a package provided the pillar condition is met.
    # salt medium77 pillar.get
    pg_version
    medium77:
    9.3
           ^^^ you want this to be '9.3' or "9.3" because you compare against
           strings later
    --snip--
    pkgrepo:
    pkg:
    - installed
    - sources:
    {% if pillar.get('pg_version') == '9.3' %}
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}
    --snip--

    When I run this I get following error message
    You state essentially means:

    Install a package called "pkgrepo" and *iff* pg_version has been set use
    salt:/files/pgdg-centos93-9.3-1.noarch.rpm as source. I am not entire sure
    which distribution you use and am not too familiar with rpm based ones so I
    cannot check, but are you sure that the package is called "pkgrepo" ?

    Because if it is not then you should provide the actual name of the package.
    IIRC package names on your system might include the version number and you
    should therefore use:

    pkgrepo:
       pkg:
         - installed
         - name: pgdg-centos93-9.3.1
         - sources:
           {% if pillar.get('pg_version') == '9.3' %}
           - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
           {% endif %}

    The name might be "pgdg-centos93" or even just plain "pgdg" (you can probably
    check that faster) but it is almost certainly not "pkgrepo" which salt will
    use if you don't supply the "name: " argument.

    I would also think that you don't want to include that state at all iff the
    pillar isn't set or do you simply want to install a different rpm if so?

    If the former use:

         {% if pillar.get('pg_version') == '9.3' %}
         pkgrepo:
           pkg.installed:
             - name: pgdg-centos93-9.3.1
             - sources:
               - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
         {% endif %}

    or even:

         {% if pillar.get('pg_version') == '9.3' %}
         pgdg-centos93-9.3.1:
           pkg.installed:
             - sources:
               - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
         {% endif %}


    and if the latter:

         pkgrepo:
           pkg.installed:
             - name: pgdg-centos93-9.3.1
         {% if pillar.get('pg_version') == '9.3' %}
             - sources:
               - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
         {% endif %}

    or:

         pgdg-centos93-9.3.1:
           pkg.installed:
         {% if pillar.get('pg_version') == '9.3' %}
             - sources:
               - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
         {% endif %}

    In every case the name (i.e. the argument to pkg.installed) must correspond to
    the name of the package you want to install. The rule is: Either use the
    name/argument as the name of the state itself (pkgrepo) or supply it as an
    explicit argument in the body which allows you to use names such as "Install
    pgdg version 9.3.1:" or so.
    --
    Wolodja <babilen@gmail.com>

    4096R/CAF14EFC
    081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC
  • T10tennn at Jul 30, 2014 at 7:36 am
    Hi,

    Thanks Wolodja for clearing that, you were spot on with the names part. My
    bad I thought the package name is pgdg-93 but it actually is
    pgdg-centos93. What threw me off was that the package was actually being
    installed just that return code was 1 and in retrospect makes sense as
    pgdg-93 was
    available on the system.
    As one is using sources one has to just define package name and point to
    the source.

    What I'm trying to do here is actually pull postgres packages from postgres
    repo.

    Finally I have a working version too ...

    --snip--
    pkgrepo:
       pkg:
         - installed
         - sources:
           {% if pillar.get('pg_version') == 9.2 %}
           - pgdg-centos92:
    ftp://t10.local/pg/centos6/pgdg-centos92-9.2-6.noarch.rpm
           {% elif pillar.get('pg_version') == 9.3 %}
           - pgdg-centos93:
    ftp://t10.local/pg/centos6/pgdg-centos93-9.3-1.noarch.rpm
           {% endif %}
    --snip--

    Thankyou all


    On Tuesday, July 29, 2014 9:19:08 PM UTC+2, Wolodja Wentland wrote:

    On Tue, Jul 29, 2014 at 04:15 -0700, t10t...@gmail.com <javascript:>
    wrote:
    Its probably a trivial issue or something I have missed.
    I need to install a package provided the pillar condition is met.
    # salt medium77 pillar.get
    pg_version
    medium77:
    9.3
    ^^^ you want this to be '9.3' or "9.3" because you compare against
    strings later
    --snip--
    pkgrepo:
    pkg:
    - installed
    - sources:
    {% if pillar.get('pg_version') == '9.3' %}
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}
    --snip--

    When I run this I get following error message
    You state essentially means:

    Install a package called "pkgrepo" and *iff* pg_version has been set use
    salt:/files/pgdg-centos93-9.3-1.noarch.rpm as source. I am not entire sure
    which distribution you use and am not too familiar with rpm based ones so
    I
    cannot check, but are you sure that the package is called "pkgrepo" ?

    Because if it is not then you should provide the actual name of the
    package.
    IIRC package names on your system might include the version number and you
    should therefore use:

    pkgrepo:
    pkg:
    - installed
    - name: pgdg-centos93-9.3.1
    - sources:
    {% if pillar.get('pg_version') == '9.3' %}
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}

    The name might be "pgdg-centos93" or even just plain "pgdg" (you can
    probably
    check that faster) but it is almost certainly not "pkgrepo" which salt
    will
    use if you don't supply the "name: " argument.

    I would also think that you don't want to include that state at all iff
    the
    pillar isn't set or do you simply want to install a different rpm if so?

    If the former use:

    {% if pillar.get('pg_version') == '9.3' %}
    pkgrepo:
    pkg.installed:
    - name: pgdg-centos93-9.3.1
    - sources:
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}

    or even:

    {% if pillar.get('pg_version') == '9.3' %}
    pgdg-centos93-9.3.1:
    pkg.installed:
    - sources:
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}


    and if the latter:

    pkgrepo:
    pkg.installed:
    - name: pgdg-centos93-9.3.1
    {% if pillar.get('pg_version') == '9.3' %}
    - sources:
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}

    or:

    pgdg-centos93-9.3.1:
    pkg.installed:
    {% if pillar.get('pg_version') == '9.3' %}
    - sources:
    - pgdg-93: salt:/files/pgdg-centos93-9.3-1.noarch.rpm
    {% endif %}

    In every case the name (i.e. the argument to pkg.installed) must
    correspond to
    the name of the package you want to install. The rule is: Either use the
    name/argument as the name of the state itself (pkgrepo) or supply it as an
    explicit argument in the body which allows you to use names such as
    "Install
    pgdg version 9.3.1:" or so.
    --
    Wolodja <bab...@gmail.com <javascript:>>

    4096R/CAF14EFC
    081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedJul 29, '14 at 11:15a
activeJul 30, '14 at 7:36a
posts6
users4

People

Translate

site design / logo © 2022 Grokbase