1

I am using `users' resource to create unix accounts and then set a default password. For this I have written the following manifest .

node 'node2.example.com','node3.example.com'{
 user {
 'askar':
  ensure  => 'present',
  managehome => 'true',
  comment => 'man Home',
  home    => '/home/askar',
  shell   => '/bin/bash',
  expiry  => '2016-03-22',
  password => '$1$cs1j/t.D$4Q2Ocr0pulyNTUx/',
  password_min_age => '30',
  password_max_age => '60',
   }
  }

It works fine, but I want the user should be forced to change his password at next login. For this I extended the rule with an exec resource to run the following command chage -d 0 askar so that the user is forced to change the password

exec {
'chage':
 command => 'chage -d 0 askar'
 }
}

But this is not working for me. Can you please suggest how can I get a user forced to change his password at next login .

0

It seems exec puppet resource looks for the command in the current directory only.

Adding the path of chage command resolved the issue for me

  $ which chage
  /usr/bin/chage

So,the exec resource declaration is as follows

 exec {
  'chage':
        path => '/usr/bin/',
        command => 'chage -d 0 askar',
      }

Verified that password expired for the user which means the user must change his password at next login.

# chage -l askar
Last password change                : Password must be changed 
Password expires                    : Password must be changed
Password inactive                   : password must be changed
Account expires                     : Mar 22, 2016
Minimum number of days between password change          : 30
Maximum number of days between password change          : 60
Number of days of warning before password expires       : 7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.