2013-07-11 68 views
4

我一直在試圖找出如何編寫,將安裝ACL包,然後用它重新掛載文件系統根目錄配方啓用:設置ACL大廚

  1. apt-get install acl
  2. 添加以 「acl」 的選項fstab中
  3. mount -o remount /

我在食譜嘗試:

case node[:platform] 
when "debian","ubuntu" 
    package "acl" do 
     action :install 
    end 

    mount "/" do 
     options "acl" 
     action [:remount, :enable] 
    end 
end 

不幸的是(並不令人驚訝)廚師不知道如何閱讀現有的fstab條目,並添加acl而不更改其他任何內容,因此它吹掉了掛載點上的現有選項。有關我如何完成此任務的任何想法?

回答

4

發現了一種與Augeas做到這一點:

# Install ACL and remount the root volume with ACL enabled 
case node[:platform] 
when "debian","ubuntu" 
    %w{acl augeas-tools}.each do |pkg| 
     package pkg 
    end 

    execute "update_fstab" do 
     command <<-EOF 
      echo 'ins opt after /files/etc/fstab/*[file="/"]/opt[last()] 
      set /files/etc/fstab/*[file="/"]/opt[last()] acl 
      save' | augtool 
      mount -o remount/
     EOF 
     not_if "augtool match '/files/etc/fstab/*[file=\"/\"]/opt' | grep acl" 
    end 
end 

我真的不喜歡的解決方案,但它似乎工作。還有更好的方法,對吧?

+0

我用你的解決方案發布了一本食譜https://supermarket.getchef.com/cookbooks/acl – Maks3w