Ask Your Question
0

How to solve the depedency in the package

asked 2015-03-11 05:11:04 -0600

akshay gravatar image
package {
"apache2_2.4.7-1ubuntu4_amd64(1)":
ensure => present,
provider => 'dpkg',
source => "/home/apache/apache2_2.4.7-1ubuntu4_amd64(1).deb",
require => File["/home/apache/apache2_2.4.7-1ubuntu4_amd64(1).deb"],
subscribe => Exec["dpkg --install"],
install_options => ["INSTLLDIR=/usr/bin:/usr/sbin:/sbin"],
}
package {
"apache2-bin_2.4.7-1ubuntu4_amd64":
ensure => present,
provider => 'dpkg',
source => "/home/apache/apache2-bin_2.4.7-1ubuntu4_amd64.deb",
require => File["/home/apache/apache2-bin_2.4.7-1ubuntu4_amd64.deb"],
subscribe => Exec["dpkg --install"],
install_options => ["INSTLLDIR=/usr/bin:/usr/sbin:/sbin"],
}
package {
"libapr1_1.5.0-1_amd64":
ensure => present,
provider => 'dpkg',
source => "/home/apache/libapr1_1.5.0-1_amd64.deb",
require => File["/home/apache/libapr1_1.5.0-1_amd64.deb"],
subscribe => Exec["dpkg --install"],
install_options => ["INSTLLDIR=/usr/bin:/usr/sbin:/sbin"],
}

I am installing the Apache 2 package on agent side and it successfully installed But the problem is when I am writing this code there is a lots of dependency in apache2 package and the code was very large I have to write multiple package section in my script So is there another way to overcome the write multiple package section? I have to write the multiple packages but in one section means package {

} in that way.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-11 05:30:19 -0600

PorkCharSui gravatar image

updated 2015-03-12 06:27:38 -0600

I think you want a 'defined type' here:

define my_apache_package { 
    file { "${name}":
        ensure => present,
        source => "puppet:///modules/${module_name}/${name}",
    }
    package {  "${name}":
        ensure => present,
        provider => 'dpkg',
        source => "/home/apache/${name}",
        require => File["/home/apache/${name}"],
        subscribe => Exec["dpkg --install"],
        install_options => ["INSTLLDIR=/usr/bin:/usr/sbin:/sbin"],
    }
}
my_apache_package { "apache2_2.4.7-1ubuntu4_amd64(1)":, } 
my_apache_package { "apache2-bin_2.4.7-1ubuntu4_amd64":, }
my_apache_package { "libapr1_1.5.0-1_amd64":, }

At the bottom the values behind myapachepackage { ... is the ${name} variable.

EDIT

You were close, but a class and a defined type are not entirely the same thing! You have to specify a define if you want to use it.

$ cat .../modules/apache_server/manifests/init.pp

class apache_server { 
  define packages {
    file { "/home/${name}":
      ensure => present,
      source => "puppet:///modules/${module_name}/${name}",
    }
    package { "${name}":
      ensure => present,
      provider => 'dpkg',
      source => "/home/${name}",
      require => File["/home/${name}"],
      subscribe => Exec["dpkg --install"],
      install_options => ["INSTALLDIR=/usr/bin:/usr/sbin:/sbin"],
    }
  } #(end defined type)
  packages { "apache2_2.4.7-1ubuntu4_amd64(1).deb":, } 
  packages { "apache2-bin_2.4.7-1ubuntu4_amd64.deb":, } 
  packages { "apache2-data_2.4.7-1ubuntu4_all.deb":, } 
  packages { "libapr1_1.5.0-1_amd64.deb":, } 
  packages { "libaprutil1_1.5.3-1_amd64.deb":, }
} #(end class)

The ${name} variable will be the *.deb packages.

EDIT Made an error in the resource name.

edit flag offensive delete link more

Comments

What is my_apache_package? Is this the class name?

akshay gravatar imageakshay ( 2015-03-11 05:36:43 -0600 )edit

You could call it the class name yes. A defined type is a class which can be evaluated several times with different values.

PorkCharSui gravatar imagePorkCharSui ( 2015-03-11 05:47:49 -0600 )edit

Thank u so much for help me. Very thanks to u.

akshay gravatar imageakshay ( 2015-03-11 05:51:24 -0600 )edit

the declaration of my_apache_package { "libapr1_1.5.0-1_amd64":, } is outside script or in that script. Where to declare the all package in script and how it fetch from '$name' variable

akshay gravatar imageakshay ( 2015-03-11 05:53:34 -0600 )edit

The declaration of my_apache_package { "libapr1_1.5.0-1_amd64":, } should be in the same class, but outside the defined type. The ${name} variable is a freebee from Puppet... it's the title of a resource type. It's used a lot in defined types, because the title of a resource always has to be unique.

PorkCharSui gravatar imagePorkCharSui ( 2015-03-11 06:04:53 -0600 )edit

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-11 05:11:04 -0600

Seen: 490 times

Last updated: Mar 12 '15