Need Guidance

Hi All,

Need your Guidance to achieve the milestone.

I am creating a playbook to validate the user password expiry date . if it expires withing 15 days it should send a mail to user mail id.
but not sure how to enable mail alter after execution of command .

Below is the palybook task detail :-

tasks:

  • name: check users password valid time
    shell: chage -l “{{ item }}”
    register: validate

loop: users

  • debug:
    msg: “{{ validate }}”
    when: validate.rc !=0

  • name: Intimate concern team by mail if lock occurs
    mail:
    host: “{{ smtp_host_name }}”
    port: “{{ smtp_port }}”
    attach:

  • /home/kundan/
    body: " password getting expires in 10 days"

“Name or service not known” tells that “smtp_host_name” is not reachable.

Thanks Abhijit

I made the changes in the code.
But still have dout how to use when condition to send a alter so that user can change there password for endpoints

Thank you so much Abhijeet.