【问题标题】:Chef user group permissions on subfoldersChef 用户组对子文件夹的权限
【发布时间】:2017-02-28 18:28:23
【问题描述】:

我正在尝试为 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

通过指定递归它没有帮助。

【问题讨论】:

标签: ruby linux chef-infra chef-recipe subdirectory


【解决方案1】:

来自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

【讨论】:

  • 我不想定义每个子文件夹。因为它们有很多和很长的文件夹层次结构。
猜你喜欢
  • 2014-10-14
  • 1970-01-01
  • 2011-03-14
  • 2018-06-12
  • 2015-05-15
  • 1970-01-01
  • 2015-07-19
  • 2013-10-26
  • 1970-01-01
相关资源
最近更新 更多