amazon-web-servicescodeigniterchef-infraaws-opsworks

Prevent OpsWorks from overwriting the CodeIgniter's "system" directory with a symlink


I have multiple CodeIgniter applications that I want to deploy with Amazon OpsWorks with a very standard "PHP App Server" layer and a custom recipe to adjust permissions. The problem is that the deploy script seems to automatically remove any current/public/system directory and replace it by a symlink to shared/system.

This is pretty annoying because all the CodeIgniter's files used to be within the current/public/system directory.

Anyone know how to prevent OpsWorks from creating this symlink ?

Thanks


Solution

  • This is not possible UNLESS you create your own modified version of the AWS Cookbook that does this. The specific reason for this is the recipes at : here

    A Possible Work around this :

    ## deploy/before_migrate.rb (in your app repo )
    
    deploy_to = deploy_resource.deploy_to
    
    dirs_to_protect = [ "public" ]
    dirs_to_protect.each {|dir| 
        bash "save #{dir}" do
          code <<-EOL
            cp -a #{release_path}/#{dir}/* #{deploy_to}/shared/#{dir} 
          EOL
        end
    }
    

    This will save the dirs you need to protect in the shared folder where the symlink is sent to. You can easily change the destination, or just write another hook after the symlink to remove the symlinked directories. etc. Keep in mind that if it's not a default folder, you will need to create it yourself inside the loop.

    More about Hooks : Chef Deployment Hooks