4

我一直在试图弄清楚如何编写一个安装 ACL 包的配方,然后在启用它的情况下重新挂载文件系统根目录:

  1. apt-get install acl
  2. 在 fstab 中的选项中添加“acl”
  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

不幸的是(并不奇怪)chef 不知道如何读取 / 的现有 fstab 条目并将 acl 添加到它而不更改任何其他内容,因此它会破坏安装点上的现有选项。关于我如何实现这一点的任何想法?

4

1 回答 1

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

我不太喜欢这个解决方案,但它似乎有效。不过一定有更好的方法,对吧?

于 2013-07-11T23:44:16.290 回答