I am using the following user resource to create a unix
user and then set an initial password for the user. I then performed an exec with chage command to force the user to change his password after his first login.The manifest is as follows
node 'node2.example.com','node3.example.com'{
user {
'askar':
ensure => 'present',
managehome => 'true',
comment => 'Laskar Home',
home => '/home/askar',
shell => '/bin/bash',
expiry => '2016-04-22',
password => '$1$T7iMiuVY$bVjrtyWV4diXBKlCgcDKT0',
password_min_age => '20',
password_max_age => '60',
}
exec {
'chage':
path => '/usr/bin/',
command => 'chage -d 0 askar',
}
}
The issue with the above manifests is that every time the agent pulls the manifests the password is again set to the default password and then the user is forced to change his password .
So, in order to avoid this I am adding the refreshonly
parameter as follows
exec {
'chage':
path => '/usr/bin/',
command => 'chage -d 0 askar',
subscribe => File['askar'],
refreshonly => true,
}
}
I then verified that after applying the refreshonly
parameter , the
password is not getting changed to the default password and also chage
in exec
is not getting executed . But I had few doubts regarding how refreshonly parameter works and I am not sure whether it is working fine for me.
1) Since refreshonly
is an exec
parameter using it inside exec
will not cause chage -d 0 askar
to execute unless there is a change in user
resource manifests. Am i correct here ? Does this also means that user
resource will also not be executed along with exec
because of the refreshonly
parameter which means the user password will not be set to default which was defined in user
resource ?
2) I tried to change password_min_age => '20' to password_min_age => '30',
now since this is a change in user
manifests , I am expecting that exec
resource will get executed with chage
command and user will be forced to change his password. But I am not seeing this change . Is my understanding wrong here ?
3) or the way I am defining refreshonly
parameter itself is wrong. The syntax should have been subscribe => User['askar'],
instead of subscribe => File['askar'],