title: Make chef cookbook recipe only run once
body: <p>So I use the following recipe:</p>
  
  <pre><code>include_recipe "build-essential"
  
  node_packages = value_for_platform(
    [ "debian", "ubuntu" ]                      =&gt; { "default" =&gt; [ "libssl-dev" ] },
    [ "amazon", "centos", "fedora", "centos" ]  =&gt; { "default" =&gt; [ "openssl-devel" ] },
    "default"   =&gt; [ "libssl-dev" ]
  )
  
  node_packages.each do |node_package|
    package node_package do
      action :install
    end
  end
  
  bash "install-node" do
    cwd Chef::Config[:file_cache_path]
    code &lt;&lt;-EOH
      tar -xzf node-v#{node["nodejs"]["version"]}.tar.gz
      (cd node-v#{node["nodejs"]["version"]} &amp;&amp; ./configure --prefix=#{node["nodejs"]["dir"]} &amp;&amp; make &amp;&amp; make install)
    EOH
    action :nothing
    not_if "#{node["nodejs"]["dir"]}/bin/node --version 2&gt;&amp;1 | grep #{node["nodejs"]["version"]}"
  end
  
  remote_file "#{Chef::Config[:file_cache_path]}/node-v#{node["nodejs"]["version"]}.tar.gz" do
    source node["nodejs"]["url"]
    checksum node["nodejs"]["checksum"]
    notifies :run, resources(:bash =&gt; "install-node"), :immediately
  end
  </code></pre>
  
  <p>It successfully installed nodejs on my Vagrant VM but on restart it's getting executed again. How do I prevent this? I'm not that good in reading ruby code.</p>