Jump to content

is it possible to set permissions on a folder outside the root using yml


ajoo
Go to solution Solved by requinix,

Recommended Posts

Hi all, 

 

I have been trying to set file and folder permissions on my projects files and folders using yml. While it works for the files on my project folder, it does not work on the folder itself, or folders in the project folder. It also does not work on folders outside the root i.e. folders on the same level as the project folder. 

 

How may I achieve this ? 

 

Thanks all !

 

Project Structure:

/project ---
 |     -- folder1                // permissions not set
 |        |-- my-file-1.txt      // permissions set
 |        |-- my-file-2.txt      // permissions set
 |     -- folder2                // permissions not set
 |        |-- my-file-3.txt      // permissions set
 | -- my-file-4.txt              // permissions set
 | -- my-file-5.txt              // permissions set 
 | -- my-file-6.txt              // permissions set
 |
 |
 outside_root ---                // permissions not set for any files or folders
 |     -- folder3
 |        |-- out-file-1.txt
 |        |-- out-file-2.txt 
 |     -- folder4
 |        |-- out-file-3.txt
 |        |-- out-file-4.txt 
 | -- out-file-5.txt 

yml file :

version: 0.0
os: linux
files:
  - source: /project
    destination: /var/www/html
  - source: /outside_root
    destination: /var/www/outside_root
# For project directory
permissions:
  - object: /var/www/html
    owner: ec2-user
    group: apache
    mode: 755
    type:
    - directory
# For outside_root directory
    - object: /var/www/outside_root
    owner: ec2-user
    group: apache
    mode: 710
    type:
    - directory
# For project files
    - object: /var/www/project
    owner: ec2-user
    group: apache
    mode: 644
    type:
    - file
# For outside_root files
    - object: /var/www/outside_root
    owner: ec2-user
    group: apache
    mode: 640
    type:
    - file

Link to comment
Share on other sites

  • Solution

Please remember to give context for people who don't know you're working with CodeDeploy.

 

It doesn't look like their permissions system is particularly powerful - since "directory" only applies to descendant directories and "file" only applies to immediate files, you would need a bunch of sections listing out each individual directory whose files you wanted to change permissions on.

 

Try deploying with a .tar/.tar.gz (and not a .zip) as those support specifying permissions inside the archive itself. No guarantee that CodeDeploy will keep the permissions on extraction, though.

 

Otherwise I think I would give up and use a post-install bash script (or individual commands without the script) to apply permissions as you want. Probably with a combination of find+xargs+chown/chmod.

  • Like 1
Link to comment
Share on other sites

Hi requinix !

 

 

 

Please remember to give context for people who don't know you're working with CodeDeploy.

 

Ya sorry, I'll keep that in mind next time. 

 

Thanks for the information. Then I'll go the manual route or create a post-install  bash as you suggest.  :thumb-up:

 

Thanks !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.