Home / Articles / Devops / puppet / 6.0 / puppet-resource-user

Resource Type: user

  • Resource Attributes:
  • user { 'resource title': name => # (namevar) The user name. While naming limitations vary by... ensure => # The basic state that the object should be in.... allowdupe => # Whether to allow duplicate UIDs. Default... attribute_membership => # Whether specified attribute value pairs should... attributes => # Specify AIX attributes for the user in an array... auth_membership => # Whether specified auths should be considered the auths => # The auths the user has. Multiple auths should... comment => # A description of the user. Generally the user's expiry => # The expiry date for this user. Provide as either forcelocal => # Forces the management of local accounts when... gid => # The user's primary group. Can be specified... groups => # The groups to which the user belongs. The... home => # The home directory of the user. The directory... ia_load_module => # The name of the I&A module to use to manage this iterations => # This is the number of iterations of a chained... key_membership => # Whether specified key/value pairs should be... keys => # Specify user attributes in an array of key ... loginclass => # The name of login class to which the user... managehome => # Whether to manage the home directory when Puppet membership => # If `minimum` is specified, Puppet will ensure... password => # The user's password, in whatever encrypted... password_max_age => # The maximum number of days a password may be... password_min_age => # The minimum number of days a password must be... password_warn_days => # The number of days before a password is going to profile_membership => # Whether specified roles should be treated as the profiles => # The profiles the user has. Multiple profiles... project => # The name of the project associated with a user. provider => # The specific backend to use for this `user... purge_ssh_keys => # Whether to purge authorized SSH keys for this... role_membership => # Whether specified roles should be considered the roles => # The roles the user has. Multiple roles should... salt => # This is the 32-byte salt used to generate the... shell => # The user's login shell. The shell must exist... system => # Whether the user is a system user, according to... uid => # The user ID; must be specified numerically. If...


    Examples:

  • Create New user 'foo'
  • user { 'Create user foo': name => 'foo' ensure => present, shell => '/bin/bash', home => '/home/foo', }
  • Add secondary group 'bar' to user 'foo'
  • user { 'Create user foo': name => 'foo' groups => 'bar', }
  • Set password for user 'foo'
  • First, generate password hash using openssl command # openssl passwd -1 Password: Verifying - Password: $1$G9csL/dp$ji1ADlvhOhVpjVMl9Fgai/ Second, add the password hash in puppet configuration user { 'Set password ': user => 'foo', password => '$1$G9csL/dp$ji1ADlvhOhVpjVMl9Fgai/', }
  • Delete user 'foo'
  • user { 'Create user foo': name => 'foo' ensure => absent, }