将域用户帐户添加到本地组Windows Puppet

时间:2012-09-20 18:24:44

标签: puppet

我正在尝试根据puppet文档将Windows域用户帐户设置为本地管理员组。

user { 'DOMAIN\user':
    groups => ['Administrators'],
}

我尝试使用SID但没有结果。我正在使用最新的Puppet 2.7.19

err: /Stage[main]/Teamcity_base/User[S-1-5-21-1759977473-2015113658-625696398-26
038]/ensure: change from absent to present failed: User update failed: SetInfo
    OLE error code:8007089A in Active Directory
      The specified username is invalid.

    HRESULT error code:0x80020009
      Exception occurred.

1 个答案:

答案 0 :(得分:2)

我目前的解决方法是使用“net localgroup”命令运行批处理文件的自定义模块:

net localgroup administrators domain\user /add

我的init.pp使用subscribe:

检测批处理文件的更改
class admin {
  $exe_name = "add_admin_users.bat"
  $location = "puppet:///modules/${module_name}/${exe_name}"
  $on_disk = 'C:\add_admin_users.bat'

  file { $on_disk:
    ensure => file,
    source => $location,
    mode   => '750',
  }

  exec { $on_disk:
    subscribe => File[$on_disk],
    refreshonly => true
  }

}

不理想,因为它在尝试添加之前不会检查用户是否存在,而是关闭。