Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (29.3k points)

I'm trying to create a puppet module which automates the installation of Zend server CE, this is not important here, but steps are as following

update /etc/apt/source.list

download repos key via wget

do apt-get update

do apt-get install Zend-server-ce-5.2

I have init.pp file

class zendserverce {

# https://github.com/puppetlabs/puppetlabs-stdlib

file_line { 'debian_package':

    path => '/etc/apt/sources.list',

    line => 'deb http://repos.zend.com/zend-server/deb server non-free'

}

exec { "wget http://repos.zend.com/zend.key -O- |apt-key add -":

    path => ["/usr/bin", "/usr/sbin"]

}

exec { "apt-get update":

    command => "/usr/bin/apt-get update",

    onlyif  => "/bin/sh -c '[ ! -f /var/cache/apt/pkgcache.bin ] || /usr/bin/find /etc/apt/* -cnewer /var/cache/apt/pkgcache.bin | /bin/grep . > /dev/null'",

}

package { "zend-server-ce-php-5.2":

    ensure => "latest"

}

}

Seems that the puppet runs commands in a different order then I need. Is there any way how to tell him to run in my desired order?

The output of such snippet is

  [0;36mnotice: /Stage[main]/Mc/Package[mc]/ensure: ensure changed 'purged' to 'latest'[0m

  [1;35merr: /Stage[main]/Zendserverce/Package[zend-server-ce-php-5.2]/ensure: change from purged to latest failed: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install zend-server-ce-php-5.2' returned 100: Reading package lists...

  Building dependency tree...

  Reading state information...

  E: Couldn't find package zend-server-ce-php-5.2 at /tmp/vagrant-puppet/modules 0/zendserverce/manifests/init.pp:28[0m

  [0;36mnotice: /Stage[main]/Zendserverce/Exec[wget http://repos.zend.com/zend.key -O- |apt-key add -]/returns: executed successfully[0m

  [0;36mnotice: /Stage[main]/Zendserverce/File_line[debian_package]/ensure: created[0m

  [0;36mnotice: Finished catalog run in 6.75 seconds[0m

So it says: Couldn't find package Zend-server-ce-php-5.2

Can anyone guide me what is wrong?

1 Answer

0 votes
by (50.2k points)

For this, you need to specify the dependency relationships. The easiest approach is to use the require parameter which is available for all resource types.

package { "zend-server-ce-php-5.2":

  ensure  => latest,

  require  => Exec['apt-get update'],

}

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...