我有以下exec将
Linux(CentOS 6)主机加入Active Directory域.当从bash终端以root用户身份运行时,它会成功运行,主机将正确加入AD域.
但是,在puppet中运行时,net ads join命令将失败:
Failed to join domain: Failed to set password for machine account
(NT_STATUS_ACCESS_DENIED)
这是执行官
exec { 'adjoin': command => "kinit adjoin@AD.EXAMPLE.COM -k -t /etc/krb5.keytab && net ads join createcomputer='Machines/Servers/Linux Servers' osName='${operatingsystem}' osVer=${operatingsystemrelease} -k",unless => "net ads testjoin -k | grep -q 'Join is OK'",provider => shell,user => root,path => '/usr/sbin:/usr/bin:/sbin:/bin',require => [ File['/etc/krb5.conf'],File['/etc/krb5.keytab'],],logoutput => true,}
我尝试过使用和不使用提供程序和用户参数.
解决方法
事实证明我必须使用exec中的environment参数显式设置一些环境变量,特别是LOGNAME:
exec { 'adjoin': command => "kinit adjoin@AD.EXAMPLE.COM -k -t /etc/krb5.keytab && net ads join createcomputer='Machines/Servers/Linux Servers' osName='${operatingsystem}' osVer=${operatingsystemrelease} -k",environment => [ 'USER=root','LOGNAME=root','HOME=/root',}
有两个原因:
> net ads -k join fails without LOGNAME env variable
> LOGNAME,USER,and HOME are specifically unset by puppet期间
一个高管的奔跑.这是一个详细的设计选择
我链接的机票.
我也为了理智而设置了USER和HOME,虽然我不确定网络广告是否需要它们.