On Sep 14, 2011, at 7:37 AM, Stoyan Nikolov wrote:

> So here is my manifest:
> 
> class aguu {
> 
>         exec { "update":
>                 command => "apt-get update",
>                 path => "/usr/bin/"
>         }
> 
>         exec { "upgrade":
>                 command => "apt-get upgrade -y",
>                 path => "/usr/bin/"
>         }
> }
> 
> It it supposed to run apt-get update + upgrade
> 
> This is the output I get:
> 
> info: Applying configuration version '1316008127'
> notice: //aguu/Exec[update]/returns: executed successfully
> err: //aguu/Exec[upgrade]/returns: change from notrun to 0 failed: apt-get 
> upgrade -y returned 100 instead of one of [0] at 
> /etc/puppet/modules/aguu/manifests/init.pp:11
> notice: //testmodule1/File[/tmp/testmodule]/ensure: created
> warning: Value of 'preferred_serialization_format' (pson) is invalid for 
> report, using default (marshal)
> notice: Finished catalog run in 3.60 seconds
> 
> Apt-get should be returning 100 in case of an error, but if i run the exact 
> same command from command line it runs fine.
> Any suggestions what should be going wrong?
----
It's entirely possible to have something blocking the run of 'apt-get -y 
upgrade' such as unresolved dependencies which may require you to execute 
'apt-get -f install' in order to get something done.

Generally, you can check the result of a command by typing 'echo $?' to see the 
exit status... ie
apt-get upgrade -y; echo $?

as for your particular issue... hard to know for sure but it may be useful to 
see how I handle this. In a general explanation, I create a directory 
/etc/puppet/deployment_files and in that directory, I sometimes put things I 
need for deployment status or triggering.

This is what my 'apt updates' class looks like...

class apt::updates {
  include mod_puppet::deployment_files
 # Puppet maintained file /etc/puppet/deployment_files/apt_update_initiator
  file { "/etc/puppet/deployment_files/apt_update_initiator":
    source      => "puppet://puppet/modules/apt/apt_update_initiator",
    require     => Class["mod_puppet::deployment_files"],
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 0644,
  }
  exec { "/usr/bin/aptitude update":
    refreshonly => true,
    subscribe   => File["/etc/puppet/deployment_files/apt_update_initiator"],
  }
 # Puppet maintained file 
/etc/puppet/deployment_files/apt_safe_upgrade_initiator
  file { "/etc/puppet/deployment_files//apt_safe_upgrade_initiator":
    source      => "puppet://puppet/modules/apt/apt_safe_upgrade_initiator",
    require     => [ Class["mod_puppet::deployment_files"], 
Exec["/usr/bin/aptitude update"] ],
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 0644,
  }
  exec { "/usr/bin/aptitude -y safe-upgrade":
    refreshonly => true,
    subscribe   => 
File["/etc/puppet/deployment_files/apt_safe_upgrade_initiator"],
  }
 # Puppet maintained file 
/etc/puppet/deployment_files/apt_full_upgrade_initiator
  file { "/etc/puppet/deployment_files/apt_full_upgrade_initiator":
    source      => "puppet://puppet/modules/apt/apt_full_upgrade_initiator",
    require     => [ Class["mod_puppet::deployment_files"], 
Exec["/usr/bin/aptitude update"] ],
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 0644,
  }
  exec { "/usr/bin/aptitude -y full-upgrade":
    refreshonly => true,
    subscribe   => 
File["/etc/puppet/deployment_files/apt_full_upgrade_initiator"],
  }
}

and so I '/bin/date > /etc/puppet/modules/apt/files/apt_update_initiator' ( and 
also to apt_safe_upgrade_initiator and apt_full_upgrade_initiator ) and the 
first time this is deployed, all three files are copied and the commands are 
executed on each client. Note that 'Exec["/usr/bin/aptitude update"]' is 
required by the 'upgrades'

Then I have a cron run every night to put the date into the 
apt_update_initiator file on the puppet master so that forces each puppet 
client to execute and I can do the same to either of the 'upgrade' files to 
force them to upgrade.

On any client, I can check 
/etc/puppet/deployment_files/apt_[update|safe_upgrade|full_upgrade]_initiator 
to see the date and time I last instructed it to update/upgrade.

Craig

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to