present-6ren">
gpt4 book ai didi

puppet - 使用 Puppet 将用户添加到多个组

转载 作者:行者123 更新时间:2023-12-04 22:05:25 26 4
gpt4 key购买 nike

我正在尝试使用 list 将用户分配到多个组,但遇到了障碍。

尝试 1:

class usergroup {

group { "user_one":
ensure => present,
gid => 500,
}
group { "user_two":
ensure => present,
gid => 501,
}
group { "dev_site_one":
ensure => present,
gid => 502,
}
group { "dev_site_two":
ensure => present,
gid => 503,
}
group { "dev_site_three":
ensure => present,
gid => 504,
}

user { "user_one":
ensure => present,
uid => 500,
gid => 500,
gid => 502,
gid => 503,
gid => 504,
}
user { "user_two":
ensure => present,
uid => 501,
gid => 501,
}

}

运行这个:
puppet apply --noop ./init.pp

产量:

Error: Duplicate parameter 'gid' for on User[user_one] at /etc/puppet/modules/webserver/manifests/init.pp:159 on node my_web_server



尝试 2:

我试图像这样打破每个 gid 声明:
class usergroup {

group { "user_one":
ensure => present,
gid => 500,
}
group { "user_two":
ensure => present,
gid => 501,
}
group { "dev_site_one":
ensure => present,
gid => 502,
}
group { "dev_site_two":
ensure => present,
gid => 503,
}
group { "dev_site_three":
ensure => present,
gid => 504,
}

user { "user_one":
ensure => present,
uid => 500,
gid => 500,
}
user { "user_one":
gid => 502,
}
user { "user_two":
ensure => present,
uid => 501,
gid => 501,
}

}

运行这个:
puppet apply --noop ./init.pp

产量:

Error: Duplicate declaration: User[user_one] is already declared in file /etc/puppet/modules/webserver/manifests/init.pp:156; cannot redeclare at /etc/puppet/modules/webserver/manifests/init.pp:160 on node my_web_server



...其中 160 是我尝试将 gid 502 分配给 user_one 的位置。

问题

有没有办法用 Puppet 分配多个组,或者我必须手动分配这些组?

最佳答案

是的,有办法!

看看 http://docs.puppetlabs.com/references/latest/type.html#user

参数 gid 指定用户的主要组,该组必须是唯一的。可以使用 groups 参数指定其他组。

假设 500 应该是主要组......

user { "user_one":
ensure => present,
uid => 500,
gid => 500,
groups => [502, 503, 504],
}

...应该做的工作。

关于puppet - 使用 Puppet 将用户添加到多个组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18751100/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com