Last active
October 22, 2015 02:26
-
-
Save tamano/3b5e844ae3bbb0e09e93 to your computer and use it in GitHub Desktop.
Check Chef's behavior about file / directory permission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################### Precondition | |
[vagrant@localhost ~]$ cat /etc/redhat-release | |
CentOS release 6.6 (Final) | |
[vagrant@localhost ~]$ chef -v | |
Chef Development Kit Version: 0.9.0 | |
chef-client version: 12.5.1 | |
berks version: 4.0.1 | |
kitchen version: 1.4.2 | |
###################################### Pre test | |
[vagrant@localhost ~]$ chef generate repo test-repo | |
[vagrant@localhost ~]$ cd test-repo/ | |
[vagrant@localhost test-repo]$ mkdir .chef | |
[vagrant@localhost test-repo]$ echo 'local_mode true' > .chef/knife.rb | |
[vagrant@localhost test-repo]$ knife zero bootstrap localhost --sudo | |
[vagrant@localhost test-repo]$ chef generate cookbook cookbooks/create_file_dir | |
[vagrant@localhost test-repo]$ vi cookbooks/create_file_dir/recipes/default.rb | |
[vagrant@localhost test-repo]$ cat cookbooks/create_file_dir/recipes/default.rb | |
file '/tmp/test-file' do | |
content 'hogehoge' | |
action :create | |
end | |
directory '/tmp/test-dir' do | |
action :create | |
end | |
[vagrant@localhost test-repo]$ knife node run_list add localhost 'recipe[create_file_dir]' | |
###################################### Test: w/o umask settings | |
[vagrant@localhost test-repo]$ knife zero converge 'name:localhost' | |
[vagrant@localhost test-repo]$ ls /tmp/ -l | |
drwxr-xr-x. 2 root root 4096 10月 22 02:13 2015 test-dir # 755 as default | |
-rw-r--r--. 1 root root 8 10月 22 02:13 2015 test-file # 644 as default | |
[vagrant@localhost test-repo]$ sudo rm -rf /tmp/test* | |
###################################### Test: with umask settings | |
[vagrant@localhost test-repo]$ sudo su - | |
[root@localhost ~]# echo 'umask 0066' > /root/.bash_profile | |
[root@localhost ~]# exit | |
[vagrant@localhost test-repo]$ knife zero converge 'name:localhost' | |
[vagrant@localhost test-repo]$ ls /tmp/ -l | |
drwxr-xr-x. 2 root root 4096 10月 22 02:16 2015 test-dir # umask has ignored | |
-rw-r--r--. 1 root root 8 10月 22 02:16 2015 test-file # umask has ignored |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment