Puppet使用密码创建用户

问题描述:

我需要使用Puppet在Linux(RedHat)中使用密码(对于IBM MQ VM框)创建一个用户帐户。Puppet使用密码创建用户

需要使用用于连接的用户标识/密码从不同服务器(Node.JS)amqps:// userid:password @ server:port连接到MQ服务器。所有与木偶自动化。

以下是我遵循的过程。

1. Logged into a test machine. Created user id/password. 
2. Picked up the hash from /etc/shadow 
3. Used that in puppet code in password field passed to code (in single quotes). 

使用的代码如下。

$api_group = 'nonprivmq' 
    $api_userid = 'mquser' 
    $api_password = 'passwordhashpickedupfrometcshadow' (used single quotes) 

    # setup group and user for publish/subscribe messages 
    group { $api_group: 
    ensure => 'present', 
    gid => '550', 
    } 

    # setup user 
    user { $api_userid: 
    ensure  => 'present', 
    uid  => '550', 
    gid  => '550', 
    home  => "/home/${api_userid}", 
    name  => $api_userid, 
    password => $api_password, 
    managehome => yes, 
    shell  => '/bin/bash', 
    require => Group[$api_group], 
    before  => Exec['EnableAuth'], 
    } 

它在不同的机器上工作不一致。适用于虚拟机,不适用于其他虚拟机。

我阅读下面的链接,并尝试列出的选项。 managing a user password for linux in puppet

选项尝试:使用openssl指令来生成密码散列,并且在木偶使用它https://gist.github.com/pschyska/26002d5f8ee0da2a9ea0 2所示 1.使用功能。 #openssl passwd -1

这两个选项都不起作用。

当我手动登录到MQ服务器并更改密码时,一切正常。所以证明创建的密码不是我想要创建的。

感谢您的帮助。

  1. UID 550已经被占用目标系统上
  2. GID 550已经被占用目标系统上
  3. 目标系统使用不同的密码散列算法(这样你的散列不被接受)

这是我的三个想法,可能会出错。

+0

uid和gid尚未被系统采用。有没有办法来验证使用了什么哈希算法。因为我通过木偶创建它们,假设它全部使用相同的算法。 –