通过需要元参数进行的 Puppet 资源排序无法正常工作

通过需要元参数进行的 Puppet 资源排序无法正常工作

在我的 puppet 配置中,我定义了一个资源类型,如下所示。在 puppet 2.7 下一切都运行良好,但升级到 puppet 3.8 后,我遇到了麻烦。当我创建用户时,运行,而exec没有usergroup先运行,因此 exec 资源的命令无法正确执行。

谁能解释一下出了什么问题?

define my_user (
  $uid,
  $fullname,
  $email,
  $group = $name,
  $ingroups = [],
  $shell = '/bin/bash',
  $home = "/home/${name}",
  $ensure = 'present',
  $sudo = 'no',
  $system_user = false,
  $ssh_key = undef,
  $ssh_key_type = undef,
) {

  group{ $name:
    ensure => present,
    gid    => $uid,
  }

  user { $name:
    ensure     => $ensure,
    comment    => $fullname,
    uid        => $uid,
    gid        => $group,
    groups     => $ingroups,
    shell      => $shell,
    home       => $home,
    managehome => true,
    require    => Group[$group],
    system     => $system_user,
  }

  exec { "${name} homedir":
    command => "/bin/cp -R /etc/skel ${home}; /bin/chown -R ${name}:${group} ${home}",
    creates => $home,
    require => User[$name],
  }

  file { "${home}/.ssh":
    ensure  => directory,
    require => [ User[$name], Exec["${name} homedir"] ],
    owner   => $name,
    group   => $name,
    mode    => '0755',
  }

  if $ssh_key {
    ssh_authorized_key{ $email:
      ensure => $ensure,
      user   => $name,
      key    => $ssh_key,
      type   => $ssh_key_type,
    }
  }
}

相关内容