I'm new to Puppet and have a question about working with dependencies.
I'm using Puppet to install Nginx 1.0.5 on Ubuntu 11.04. It requires adding a new apt repository since natty normally comes with Nginx 0.8. At the commandline, the install goes like this:
# apt-get install python-software-properties
# add-apt-repository ppa:nginx/stable
# apt-get update
# apt-get install nginx
So I wrote this Puppet script:
class nginx::install {
package { "nginx":
ensure => present,
require => Exec["nginx_repository"],
}
exec { "add-apt-repository ppa:nginx/stable && apt-get update":
alias => "nginx_repository",
require => Package["python-software-properties"],
}
package { "python-software-properties":
ensure => installed,
}
}
The script works, but the exec{} directive runs every time, instead of only when nginx is actually being installed. Ideally, I'd like the "apt" commands to be run only before actual nginx installation, not when nginx installation is simply being checked.
I have a rudimentary understanding of the notify/subscribe model, but I wasn't sure how to have the nginx directive send a "notify" signal only when actually installing nginx.