title: OpsWorks / Chef PHP deploy process
body: <p>I'm having some serious frustration getting a simple PHP application to deploy reliably using OpsWorks, I can't find any documentation of how the <code>srv/www/app-name/releases</code> directory is managed, but I think that may been the cause of my current problem.</p>
  
  <p>I'm deploying a Laravel application, so I need two things to happen with chef recipes on deploy: composer install, and some directories to be made writable. Composer does seem to be installing fine, but my recipe to create &amp; chmod the directories seems to happen to the previous release - which makes no sense to me at all.</p>
  
  <p>Install composer:</p>
  
  <pre><code>node[:deploy].each do |application, deploy|
    script "composer-install" do
      interpreter "bash"
      cwd "#{deploy[:deploy_to]}/current"
      user "root"
      code &lt;&lt;-EOH
      composer install
      EOH
    end
  end
  </code></pre>
  
  <p>This works fine, I can refresh the vendor directory as this runs see the dependencies appearing. But the next recipe to run:</p>
  
  <pre><code>node[:deploy].each do |application, deploy|
      Chef::Log.info("Application path: #{deploy[:deploy_to]}");
  
      node['directories'].each do |path|
  
          # Get the path we need
          new_path = "#{deploy[:deploy_to]}/current/"+path
  
          Chef::Log.info("Checking directory: "+new_path);
  
          # Ensure the dir exists
          unless File.exists?(new_path)
              Chef::Log.info("Creating directory: "+new_path);
              Dir.mkdir( new_path, 777 )
          end
  
          # Ensure its writable
          File.chmod( 777, new_path )
  
      end
  end
  </code></pre>
  
  <p>The content from <code>Chef::log</code> does appear in the log, there are no errors, but the directories are simply not there - they are created in the PREVIOUS <code>release/timestamp</code> directory, as if the 'current' symlink has reverted back for the duration of this recipe. They are also created with permissions '411'.</p>
  
  <p>Can anyone explain where I'm going wrong here?
  Can I access the new directory path instead of using the 'current' symlink?</p>