我正在尝试在Linux环境中为子文件夹授予用户组权限。在Linux中将是:
chown -R user:group /var/lib/temp/*
如何在使用Ruby的Chef中实现相同的目标?我试过这个:
directory '/opt/jenkins/plugins' do
owner 'jenkins'
group 'jenkins'
mode '0755'
recursive true
action :create
end
通过指定递归,它没有帮助。
答案 0 :(得分:0)
来自chef docs:
recursive
Ruby Types: TrueClass, FalseClass
Create or delete parent directories recursively. For the owner, group, and mode properties, the value of this attribute applies only to the leaf directory. Default value: false.
用户和群组权限无法递归,您必须手动在每个子目录上设置它们。
通过执行以下操作,您可以稍微轻松一点:
plugins = %w(plugin1 plugin2)
plugins.each do |plugin|
directory "/opt/jenkins/plugins/#{plugin}" do
owner 'jenkins'
group 'jenkins'
mode '0755'
action :create
end
end