Gino Lisignoli
2012-Mar-30 01:50 UTC
[Puppet Users] apt-get update before package installations
I''m stupidly new to puppet and have taken over someone''s "in-progress-to-be-completed" implementation of puppet. I''m trying to see how I can run apt-get update before any package installs. I''ve googled around found some articles but they don''t seem to work (or rather I most likely don''t understand them). The situation I have is: Contains our sites /etc/puppet/manifests/sites.pp =============================import "classes/*" import "common" node "TestBaseServer" { include ssh_keys include puppet include test_apt include base_software include profile include core_servers_software include admin_tools include core_servers_config include build_servers_software include exim } The basic list of packages to be installed /etc/puppet/manifest/classes/base_software =========================================class base_software { Package { require => [Class[''test_apt''],Class[''apt::update'']] } package { "debian-keyring": ensure => latest } package { "vim": ensure => latest } package { "ethtool": ensure => latest } package { "tcpdump": ensure => latest } package { "rsync": ensure => latest } } The class I have create. /etc/puppet/modules/apt/manifests/update.pp ===========================================define apt::update { exec {''/usr/bin/apt-get update'':} } root@zvsv02:~# puppetd --test --noop err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could n ot find class apt::update at /etc/puppet/manifests/classes/base_software:6 on no de zvsv02.opus.co.nz So what I''m not sure about the current system is while I have defined the class in /etc/puppet/module/apt/manifests, the file that is trying to use the defined class is in /etc/puppet/manifests/classes I''m not really sure exactly how this is supposed to work. If I''m reading the documentaton right, then everything in the modules should be self contained, so I''m guessing calling apt::update from /etc/puppet/manifests/classes while the class sits in /etc/puppet/modules/apt won''t work? I can replace the line: [Class[''test_apt''],Class[''apt::update'']] With:[Class[''test_apt''],Class[''apt'']] and it finds the ''apt'' class fine. I''m confused. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Denmat
2012-Mar-30 23:26 UTC
Re: [Puppet Users] apt-get update before package installations
Hi Gino, The good news with a work in progress is that you can start all over again ;) What you are trying to call is a define: http://docs.puppetlabs.com/learning/definedtypes.html http://docs.puppetlabs.com/guides/language_guide.html#resource-collections I would also take a look at this: http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html Here''s what I would do now. 1. Remove the import classes in site.pp 2. Make a module called base (or whatever name you want) mkdir -p /etct/puppet/modules/base/manifests 3. Create an init.pp file and copy your existing package requirements into it. 4. In your apt module (modules/apt/manifests) create an init.pp This can be like (for now): class apt { } 5. Change your update exec to a class in the file apt_update.pp Like so: class apt::apt_update { exec { .....} } Now in your base module you would have something like this: class base { include apt::apt_update Package [ require => Exec[''apt_update''] ] $package_list = [''a'', ''b''] package {$package_list: } } Something like that should work - but hopefully you''ll get the idea. You can still use defines in require statements but the syntax is different (see docs). Cheers, Den On 30/03/2012, at 12:50, Gino Lisignoli <gino.lisignoli@opus.co.nz> wrote:> I''m stupidly new to puppet and have taken over someone''s "in-progress-to-be-completed" implementation of puppet. > I''m trying to see how I can run apt-get update before any package installs. I''ve googled around found some articles but they don''t seem to work (or rather I most likely don''t understand them). > > The situation I have is: > > Contains our sites > /etc/puppet/manifests/sites.pp > =============================> import "classes/*" > import "common" > > node "TestBaseServer" { > include ssh_keys > include puppet > include test_apt > include base_software > include profile > include core_servers_software > include admin_tools > include core_servers_config > include build_servers_software > include exim > } > > The basic list of packages to be installed > /etc/puppet/manifest/classes/base_software > =========================================> class base_software { > Package { > require => [Class[''test_apt''],Class[''apt::update'']] > } > package { "debian-keyring": ensure => latest } > package { "vim": ensure => latest } > package { "ethtool": ensure => latest } > package { "tcpdump": ensure => latest } > package { "rsync": ensure => latest } > } > > The class I have create. > /etc/puppet/modules/apt/manifests/update.pp > ===========================================> define apt::update { > exec {''/usr/bin/apt-get update'':} > } > > > root@zvsv02:~# puppetd --test --noop > err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could n > ot find class apt::update at /etc/puppet/manifests/classes/base_software:6 on no > de zvsv02.opus.co.nz > > So what I''m not sure about the current system is while I have defined the class in /etc/puppet/module/apt/manifests, the file that is trying to use the defined class is in /etc/puppet/manifests/classes > > I''m not really sure exactly how this is supposed to work. If I''m reading the documentaton right, then everything in the modules should be self contained, so I''m guessing calling apt::update from /etc/puppet/manifests/classes while the class sits in /etc/puppet/modules/apt won''t work? I can replace the line: [Class[''test_apt''],Class[''apt::update'']] > With: [Class[''test_apt''],Class[''apt'']] and it finds the ''apt'' class fine. > > I''m confused. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Gino Lisignoli
2012-Apr-02 03:22 UTC
Re: [Puppet Users] apt-get update before package installations
This worked perfectly! Thanks! Reading the documentation again now :) On 31/03/12 12:26, Denmat wrote:> Hi Gino, > > The good news with a work in progress is that you can start all over > again ;) > > What you are trying to call is a define: > > http://docs.puppetlabs.com/learning/definedtypes.html > > http://docs.puppetlabs.com/guides/language_guide.html#resource-collections > > I would also take a look at this: > http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html > > Here''s what I would do now. > > 1. Remove the import classes in site.pp > 2. Make a module called base (or whatever name you want) > mkdir -p /etct/puppet/modules/base/manifests > 3. Create an init.pp file and copy your existing package requirements > into it. > 4. In your apt module (modules/apt/manifests) create an init.pp > This can be like (for now): > class apt { > } > 5. Change your update exec to a class in the file apt_update.pp > Like so: > class apt::apt_update { > exec { .....} > } > > Now in your base module you would have something like this: > class base { > include apt::apt_update > Package [ require => Exec[''apt_update''] > ] > > $package_list = [''a'', ''b''] > > package {$package_list: } > } > > Something like that should work - but hopefully you''ll get the idea. > You can still use defines in require statements but the syntax is > different (see docs). > > Cheers, > Den > On 30/03/2012, at 12:50, Gino Lisignoli <gino.lisignoli@opus.co.nz > <mailto:gino.lisignoli@opus.co.nz>> wrote: >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.