title: How to work with Puppet dependencies when installing Nginx 1.0.5 on Ubuntu 11.04
body: <p>I'm new to Puppet and have a question about working with dependencies.</p>
  
  <p>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:</p>
  
  <pre><code># apt-get install python-software-properties
  # add-apt-repository ppa:nginx/stable
  # apt-get update
  # apt-get install nginx
  </code></pre>
  
  <p>So I wrote this Puppet script:</p>
  
  <pre><code>class nginx::install {
    package { "nginx":
      ensure =&gt; present,
      require =&gt; Exec["nginx_repository"],
    }
  
    exec { "add-apt-repository ppa:nginx/stable &amp;&amp; apt-get update":
      alias =&gt; "nginx_repository",
      require =&gt; Package["python-software-properties"],
    }
  
    package { "python-software-properties":
      ensure =&gt; installed,
    }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>