我正在尝试使用清单将用户分配到多个组,但我遇到了困难。
尝试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
产量:
错误:节点 my_web_server 上 /etc/puppet/modules/webserver/manifests/init.pp:159 上的用户 [user_one] 的重复参数“gid”
尝试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
产量:
错误:重复声明:用户 [user_one] 已在文件 /etc/puppet/modules/webserver/manifests/init.pp:156 中声明;无法在节点 my_web_server 上的 /etc/puppet/modules/webserver/manifests/init.pp:160 重新声明
...其中 160 是我尝试将 gid 502 分配给 user_one 的位置。
问题
有没有办法用 Puppet 分配多个组,还是我必须手动分配这些组?