Ask Your Question
0

Resource Ordering with conditional and variable

asked 2015-03-20 01:59:44 -0500

Alexandre Andrade gravatar image

Guys, I'm trying to guarantee that the packages in the variable get installed only after the "apt-get update" occurs or the "yum repository" be added. Please check the code bellow. If tried to do so using:

  • before => Package[$packages_install]
  • before => Package['$packages_install']
  • before => Package["$packages_install"]

And so on within the "if" block, it all fails. Is there another way to declare it?

if $::osfamily == 'RedHat' {
      yumrepo { 'epel':
        baseurl  => 'http://download.fedoraproject.org/pub/epel/5/i386/',
        descr    => 'Extra Packages for Enterprise Linux 5 ',
        enabled  => 1,
        gpgcheck => 0,
        before   => Package[$packages_install]
      }
    }
    if $::osfamily == 'Debian' {
      exec { 'apt-get update':
        command => "/usr/bin/apt-get update",
        before  => Package["$packages_install"]
      }
    }
    package { $packages_install:
            ensure        => latest,
            allow_virtual => false,
    } ->
    package { $packages_purge:
            ensure        => purged,
            allow_virtual => false
    }

Regards,

Alexandre

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-20 16:52:41 -0500

lorcutt gravatar image

Use stages to make sure that your yum repos are installed before anything else.

For example:

  stage { 'yum_prelim':
    before => Stage['main'],
  }
  class{ '::yum':
    stage => yum_prelim,
  }
  class yum {
    yumrepo { 'epel':
      baseurl  => 'http://download.fedoraproject.org/pub/epel/5/i386/',
      descr    => 'Extra Packages for Enterprise Linux 5 ',
      enabled  => 1,
      gpgcheck => 0,
      before   => Package[$packages_install]
      stage => yum_prelim,
    }
  }
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-20 01:59:44 -0500

Seen: 339 times

Last updated: Mar 20 '15