We have a setup to provision EC2 server in cloud and deploy application using ansible on it, and it all happens via a Jenkins pipeline job. Now, the issue is, we are using an AMI to provision EC2 and that has a policy to expire the user's password after one month. So, whenever we provision a new EC2 server, we get it with already expired password and our Ansible playbook fails because of this reason.
I am looking for some solution (whether it's via Jenkins or Shell Script or Ansible) that verifies whether the password is already expired or not? and if expired, then set the new password for the user.
I have already tried the Ansible solution and it's able to change the password for the first run, but it fails the job/task if the password is not expired already.
https://gist.github.com/netvoip/7375604e57bca37b3e4ed04b8f55820a
I need a solution which first verify if the password is expired and change if needed remotely.
Thanks in advance..!