Setting up an ACL on Ubuntu 12.04 with a chef

I tried to figure out how to write a recipe that will install the ACL package, and then reinstall the file system root directory with it turned on:

  • apt-get install acl
  • Add "acl" to options in fstab
  • mount -o remount /

My recipe attempt:

 case node[:platform] when "debian","ubuntu" package "acl" do action :install end mount "/" do options "acl" action [:remount, :enable] end end 

Unfortunately (and not surprisingly), the chef does not know how to read the existing fstab entry for / and add acl to it without changing anything to blow away existing options at the mount point. Any thoughts on how I can do this?

+4
source share
1 answer

Found a way to do this with 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 

I don't like this solution, but it seems to work. However, there must be a better way, right?

+4
source

Source: https://habr.com/ru/post/1491016/


All Articles